Jean-Marc Lasgouttes wrote:
"Abdelrazak" == Abdelrazak Younes <[EMAIL PROTECTED]> writes:
Abdelrazak> 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.
Abdelrazak> OK, try this one then. Please test also the opening when
Abdelrazak> LyX is also running.
I think you need a stack/vector of files names. I suspect you can get
several FileOpen messages.
Updated patch taking this in consideration. Please try with multiple files.
Abdel.
Index: GuiApplication.cpp
===================================================================
--- GuiApplication.cpp (revision 18060)
+++ GuiApplication.cpp (working copy)
@@ -53,6 +53,7 @@
#include <boost/bind.hpp>
#include <exception>
+#include <vector>
using std::string;
using std::endl;
@@ -162,9 +163,25 @@
}
+namespace {
+static std::vector<docstring> files_to_open_at_startup;
+}
+
+
void GuiApplication::execBatchCommands()
{
LyX::ref().execBatchCommands();
+
+ if (files_to_open_at_startup.empty())
+ return;
+
+ size_t n = files_to_open_at_startup.size();
+ for (size_t i = 0; i != n; ++i)
+ lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
+ files_to_open_at_startup[i]));
+
+ /// saves some bits of memory.
+ files_to_open_at_startup.clear();
}
@@ -207,8 +224,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.
+
files_to_open_at_startup.push_back(qstring_to_ucs4(foe->file()));
+ else
+ lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
+ qstring_to_ucs4(foe->file())));
+
+ e->accept();
return true;
}
default: