mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 08:59:28 +02:00
Fixes bug #202 based on patch by Tobias Platen
Tobias's patch was fine, but it didn't properly exclude wxMac and exposed a bug that would cause Audacity to crash at termination.
This commit is contained in:
parent
90aafd1ddc
commit
bd2ab22001
@ -564,7 +564,7 @@ GnomeShutdown GnomeShutdownInstance;
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW_) || defined(__WXGTK__)
|
||||||
|
|
||||||
//
|
//
|
||||||
// DDE support for opening multiple files with one instance
|
// DDE support for opening multiple files with one instance
|
||||||
@ -609,17 +609,24 @@ public:
|
|||||||
project->GetEventHandler()->AddPendingEvent(e);
|
project->GetEventHandler()->AddPendingEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete this;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
virtual bool OnDisconnect()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class IPCServ : public wxServer
|
class IPCServ : public wxServer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IPCServ()
|
IPCServ(const wxString & appl)
|
||||||
: wxServer()
|
: wxServer()
|
||||||
{
|
{
|
||||||
Create(IPC_APPL);
|
Create(appl);
|
||||||
};
|
};
|
||||||
|
|
||||||
~IPCServ()
|
~IPCServ()
|
||||||
@ -636,7 +643,7 @@ public:
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__WXMSW__
|
#endif
|
||||||
|
|
||||||
#ifndef __WXMAC__
|
#ifndef __WXMAC__
|
||||||
IMPLEMENT_APP(AudacityApp)
|
IMPLEMENT_APP(AudacityApp)
|
||||||
@ -1586,6 +1593,11 @@ bool AudacityApp::CreateSingleInstanceChecker(wxString dir)
|
|||||||
wxString name = wxString::Format(wxT("audacity-lock-%s"), wxGetUserId().c_str());
|
wxString name = wxString::Format(wxT("audacity-lock-%s"), wxGetUserId().c_str());
|
||||||
mChecker = new wxSingleInstanceChecker();
|
mChecker = new wxSingleInstanceChecker();
|
||||||
|
|
||||||
|
wxString appl = IPC_APPL;
|
||||||
|
#if defined(__WXGTK__)
|
||||||
|
appl.Printf(wxT("%s/%s.sock"), dir.c_str(), IPC_APPL);
|
||||||
|
#endif
|
||||||
|
|
||||||
wxString runningTwoCopiesStr = _("Running two copies of Audacity simultaneously may cause\ndata loss or cause your system to crash.\n\n");
|
wxString runningTwoCopiesStr = _("Running two copies of Audacity simultaneously may cause\ndata loss or cause your system to crash.\n\n");
|
||||||
|
|
||||||
if (!mChecker->Create(name, dir)) {
|
if (!mChecker->Create(name, dir)) {
|
||||||
@ -1606,24 +1618,29 @@ bool AudacityApp::CreateSingleInstanceChecker(wxString dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( mChecker->IsAnotherRunning() ) {
|
else if ( mChecker->IsAnotherRunning() ) {
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__) || defined(__WXGTK__)
|
||||||
//
|
//
|
||||||
// On Windows (and possibly Linux?), we attempt to make
|
// On Windows and Linux, we attempt to make a connection
|
||||||
// a DDE connection to an already active Audacity. If
|
// to an already active Audacity. If successful, we send
|
||||||
// successful, we send the first command line argument
|
// the first command line argument (the audio file name)
|
||||||
// (the audio file name) to that Audacity for processing.
|
// to that Audacity for processing.
|
||||||
wxClient client;
|
wxClient client;
|
||||||
wxConnectionBase *conn;
|
wxConnectionBase *conn;
|
||||||
|
|
||||||
// We try up to 10 times since there's a small window
|
// We try up to 10 times since there's a small window
|
||||||
// where the DDE server may not have been fully initialized
|
// where the DDE server on Windows may not have been fully
|
||||||
// yet.
|
// initialized.
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
conn = client.MakeConnection(wxEmptyString,
|
conn = client.MakeConnection(wxEmptyString,
|
||||||
IPC_APPL,
|
appl,
|
||||||
IPC_TOPIC);
|
IPC_TOPIC);
|
||||||
if (conn) {
|
if (conn) {
|
||||||
if (conn->Execute(argv[1])) {
|
bool ok = conn->Execute(argv[1]);
|
||||||
|
|
||||||
|
conn->Disconnect();
|
||||||
|
delete conn;
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
// Command was successfully queued so exit quietly
|
// Command was successfully queued so exit quietly
|
||||||
delete mChecker;
|
delete mChecker;
|
||||||
return false;
|
return false;
|
||||||
@ -1644,9 +1661,9 @@ bool AudacityApp::CreateSingleInstanceChecker(wxString dir)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__) || defined(__WXGTK__)
|
||||||
// Create the DDE server
|
// Create the DDE server
|
||||||
mIPCServ = new IPCServ();
|
mIPCServ = new IPCServ(appl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1811,7 +1828,7 @@ int AudacityApp::OnExit()
|
|||||||
Dispatch();
|
Dispatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__) || defined(__WXGTK__)
|
||||||
delete mIPCServ;
|
delete mIPCServ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ class AudacityApp:public wxApp {
|
|||||||
|
|
||||||
bool mWindowRectAlreadySaved;
|
bool mWindowRectAlreadySaved;
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__) || defined(__WXGTK__)
|
||||||
IPCServ *mIPCServ;
|
IPCServ *mIPCServ;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user