• R/O
  • SSH
  • HTTPS

molby: Commit


Commit MetaInfo

Revision612 (tree)
Time2018-03-22 08:46:44
Authortoshinagata1964

Log Message

Mac: fix unstable behavior on drag-and-dropping a log file on the application icon.

Change Summary

Incremental Difference

--- trunk/wxSources/MyApp.cpp (revision 611)
+++ trunk/wxSources/MyApp.cpp (revision 612)
@@ -88,7 +88,7 @@
8888
8989 BEGIN_EVENT_TABLE(MyApp, wxApp)
9090 EVT_COMMAND(MyDocumentEvent_scriptMenuModified, MyDocumentEvent, MyApp::OnScriptMenuModified)
91- EVT_COMMAND(MyDocumentEvent_openFilesByIPC, MyDocumentEvent, MyApp::OnOpenFilesByIPC)
91+ EVT_COMMAND(MyDocumentEvent_openFilesByEvent, MyDocumentEvent, MyApp::OnOpenFilesByEvent)
9292 EVT_UPDATE_UI_RANGE(myMenuID_MyFirstMenuItem, myMenuID_MyLastMenuItem, MyApp::OnUpdateUI)
9393 EVT_MENU(myMenuID_ExecuteScript, MyApp::OnExecuteScript)
9494 EVT_MENU(myMenuID_OpenConsoleWindow, MyApp::OnOpenConsoleWindow)
@@ -342,7 +342,7 @@
342342 files.append(argv[i]);
343343 files.append(wxT("\n"));
344344 }
345- OnOpenFiles(files);
345+ RequestOpenFilesByEvent(files);
346346 }
347347
348348 gInitCompleted = true;
@@ -542,8 +542,8 @@
542542 void
543543 MyApp::MacOpenFile(const wxString &fileName)
544544 {
545- wxString files(fileName);
546- OnOpenFiles(files);
545+ wxString file(fileName);
546+ RequestOpenFilesByEvent(file);
547547 }
548548
549549 /* Open given files: instead of calling MacOpenFile() for each entry, build a file list
@@ -1162,21 +1162,29 @@
11621162 }
11631163
11641164 void
1165-MyApp::RequestOpenFilesByIPC(wxString& files)
1165+MyApp::RequestOpenFilesByEvent(wxString& files)
11661166 {
11671167 if (m_pendingFilesToOpen != NULL)
11681168 m_pendingFilesToOpen->Append(files);
11691169 else
11701170 m_pendingFilesToOpen = new wxString(files);
1171- wxCommandEvent myEvent(MyDocumentEvent, MyDocumentEvent_openFilesByIPC);
1171+ if (!m_pendingFilesToOpen->EndsWith(wxT("\n")))
1172+ m_pendingFilesToOpen->Append(wxT("\n"));
1173+ wxCommandEvent myEvent(MyDocumentEvent, MyDocumentEvent_openFilesByEvent);
11721174 wxPostEvent(this, myEvent);
11731175 }
11741176
11751177 void
1176-MyApp::OnOpenFilesByIPC(wxCommandEvent& event)
1178+MyApp::OnOpenFilesByEvent(wxCommandEvent& event)
11771179 {
11781180 if (m_pendingFilesToOpen == NULL)
11791181 return;
1182+ if (!gInitCompleted) {
1183+ // Repost this event and try again later
1184+ wxCommandEvent myEvent(MyDocumentEvent, MyDocumentEvent_openFilesByEvent);
1185+ wxPostEvent(this, myEvent);
1186+ return;
1187+ }
11801188 OnOpenFiles(*m_pendingFilesToOpen);
11811189 delete m_pendingFilesToOpen;
11821190 m_pendingFilesToOpen = NULL;
--- trunk/wxSources/MyApp.h (revision 611)
+++ trunk/wxSources/MyApp.h (revision 612)
@@ -177,8 +177,8 @@
177177
178178 void OnActivate(wxActivateEvent &event);
179179
180- void RequestOpenFilesByIPC(wxString& files);
181- void OnOpenFilesByIPC(wxCommandEvent& event);
180+ void RequestOpenFilesByEvent(wxString& files);
181+ void OnOpenFilesByEvent(wxCommandEvent& event);
182182
183183 bool OnOpenFiles(const wxString &files);
184184
@@ -226,7 +226,7 @@
226226 MyDocument **m_TimerDocs;
227227 wxTimer *m_Timer;
228228
229- wxString *m_pendingFilesToOpen; /* Files to be processed by OnOpenFilesByIPC() */
229+ wxString *m_pendingFilesToOpen; /* Files to be processed by OnOpenFilesByEvent() */
230230
231231 wxTopLevelWindow *m_frameToBeDestroyed; /* Used in CheckIfAllWindowsAreGone() */
232232
--- trunk/wxSources/MyDocument.h (revision 611)
+++ trunk/wxSources/MyDocument.h (revision 612)
@@ -37,7 +37,7 @@
3737 MyDocumentEvent_updateDisplay,
3838 MyDocumentEvent_insertFrameFromMD,
3939 MyDocumentEvent_threadTerminated,
40- MyDocumentEvent_openFilesByIPC,
40+ MyDocumentEvent_openFilesByEvent,
4141 MyDocumentEvent_documentWillClose,
4242 MyDocumentEvent_openAuxiliaryDocuments
4343 };
--- trunk/wxSources/MyIPCSupport.cpp (revision 611)
+++ trunk/wxSources/MyIPCSupport.cpp (revision 612)
@@ -74,7 +74,7 @@
7474 {
7575 if (topic == MOLBY_IPC_TOPIC) {
7676 wxString files((wxChar *)data);
77- wxGetApp().RequestOpenFilesByIPC(files);
77+ wxGetApp().RequestOpenFilesByEvent(files);
7878 return true;
7979 } else return false;
8080 }
Show on old repository browser