Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv30924
Modified Files:
AudacityApp.h AudacityApp.cpp
Log Message:
Fix recursion crashes when multiple files are opened with Apple Events.
Index: AudacityApp.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- AudacityApp.h 24 Jul 2007 10:45:34 -0000 1.36
+++ AudacityApp.h 28 Jul 2007 07:21:53 -0000 1.37
@@ -107,6 +107,7 @@
virtual void MacPrintFile(const wxString &fileName) ;
virtual void MacNewFile() ;
virtual void MacReopenApp() ;
+ void OnMacOpenFile(wxCommandEvent & event);
#endif
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) &&
!defined(__CYGWIN__)
Index: AudacityApp.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.cpp,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -d -r1.176 -r1.177
--- AudacityApp.cpp 5 Jul 2007 11:55:35 -0000 1.176
+++ AudacityApp.cpp 28 Jul 2007 07:21:53 -0000 1.177
@@ -344,30 +344,30 @@
#ifdef __WXMAC__
+#include <wx/recguard.h>
+
// in response of an open-document apple event
void AudacityApp::MacOpenFile(const wxString &fileName)
{
- if (!gInited)
+ if (!gInited) {
return;
-
- AudacityProject *project = GetActiveProject();
- if (project == NULL || !project->GetTracks()->IsEmpty()) {
- project = CreateNewAudacityProject(gParentWindow);
}
- project->OpenFile(fileName);
+
+ wxCommandEvent e(EVT_OPEN_AUDIO_FILE);
+ e.SetString(fileName);
+ AddPendingEvent(e);
}
// in response of a print-document apple event
void AudacityApp::MacPrintFile(const wxString &fileName)
{
- if (!gInited)
+ if (!gInited) {
return;
-
- AudacityProject *project = GetActiveProject();
- if (project == NULL || !project->GetTracks()->IsEmpty()) {
- project = CreateNewAudacityProject(gParentWindow);
}
- project->OpenFile(fileName);
+
+ wxCommandEvent e(EVT_OPEN_AUDIO_FILE);
+ e.SetString(fileName);
+ AddPendingEvent(e);
}
// in response of a open-application apple event
@@ -379,8 +379,9 @@
// This method should only be used on the Mac platform
// when no project windows are open.
- if(gAudacityProjects.GetCount() == 0)
+ if (gAudacityProjects.GetCount() == 0) {
CreateNewAudacityProject(gParentWindow);
+ }
}
// in response of a reopen-application apple event
@@ -388,6 +389,27 @@
{
// Not sure what to do here...bring it to the foreground???
}
+
+void AudacityApp::OnMacOpenFile(wxCommandEvent & event)
+{
+ // Add name to queue
+ static wxArrayString ofqueue;
+ ofqueue.Add(event.GetString());
+
+ // Do not attempt to load more than one file at a time
+ static wxRecursionGuardFlag guardflag;
+ wxRecursionGuard guard(guardflag);
+ if (guard.IsInside()) {
+ return;
+ }
+
+ // Load each file on the queue
+ while (ofqueue.GetCount()) {
+ wxString name(ofqueue[0]);
+ ofqueue.RemoveAt(0);
+ MRUOpen(name);
+ }
+}
#endif
typedef int (AudacityApp::*SPECIALKEYEVENT)(wxKeyEvent&);
@@ -402,6 +424,8 @@
EVT_MENU(wxID_ABOUT, AudacityApp::OnMenuAbout)
EVT_MENU(wxID_PREFERENCES, AudacityApp::OnMenuPreferences)
EVT_MENU(wxID_EXIT, AudacityApp::OnMenuExit)
+
+ EVT_COMMAND(wxID_ANY, EVT_OPEN_AUDIO_FILE, AudacityApp::OnMacOpenFile)
#endif
// Recent file event handlers.
EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, AudacityApp::OnMRUFile)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs