Bennett Helm wrote:
On Apr 27, 2007, at 9:38 AM, Abdelrazak Younes wrote:

Silly me! Try this one.

This time no crash, but the file does not open.

OK, try this one then. Please test also the opening when LyX is also running.

Abdel.
Index: GuiApplication.cpp
===================================================================
--- GuiApplication.cpp  (revision 18060)
+++ GuiApplication.cpp  (working copy)
@@ -162,9 +162,18 @@
 }
 
 
+namespace {
+static docstring file_open_from_desktop;
+}
+
+
 void GuiApplication::execBatchCommands()
 {
        LyX::ref().execBatchCommands();
+
+       if (!file_open_from_desktop.empty())
+               lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
+                       file_open_from_desktop));
 }
 
 
@@ -207,8 +216,17 @@
        case QEvent::FileOpen: {
                // Open a file; this happens only on Mac OS X for now
                QFileOpenEvent * foe = static_cast<QFileOpenEvent *>(e);
-               lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
-                                         fromqstr(foe->file())));
+
+               if (!currentView() || !currentView()->view())
+                       // The application is not properly initialized yet
+                       // So we acknowledge the event and delay the file 
opening
+                       // until LyX is ready.
+                       file_open_from_desktop = qstring_to_ucs4(foe->file());
+               else
+                       lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
+                               qstring_to_ucs4(foe->file())));
+
+               e->accept();
                return true;
        }
        default:

Reply via email to