Abdelrazak Younes wrote:
Bennett Helm wrote:
On Apr 27, 2007, at 10:38 AM, Abdelrazak Younes wrote:
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.
This patch works, too.
I did notice when trying this patch that when I drag a file to the
dock icon that is already loaded via sessions, I get the "The document
foo.lyx is already loaded. Do you want to revert to the saved
version?" dialog. That should probably be suppressed.
Yes. Using the already existing framework for initial file loading
should solve this. But this is more work :-(
I'll see what I can do.
OK, I've done it. Please test (together with session).
Abdel.
Index: frontends/qt4/GuiApplication.cpp
===================================================================
--- frontends/qt4/GuiApplication.cpp (revision 18191)
+++ frontends/qt4/GuiApplication.cpp (working copy)
@@ -22,6 +22,7 @@
#include "graphics/LoaderQueue.h"
+#include "support/FileName.h"
#include "support/lstrings.h"
#include "support/os.h"
#include "support/Package.h"
@@ -53,6 +54,7 @@
#include <boost/bind.hpp>
#include <exception>
+#include <vector>
using std::string;
using std::endl;
@@ -75,6 +77,8 @@
namespace lyx {
+using support::FileName;
+
frontend::Application * createApplication(int & argc, char * argv[])
{
return new frontend::GuiApplication(argc, argv);
@@ -207,8 +211,18 @@
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.
+ // FIXME UNICODE: FileName accept an utf8 encoded
string.
+
LyX::ref().addFileToLoad(FileName(fromqstr(foe->file())));
+ else
+ lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
+ qstring_to_ucs4(foe->file())));
+
+ e->accept();
return true;
}
default:
Index: LyX.cpp
===================================================================
--- LyX.cpp (revision 18191)
+++ LyX.cpp (working copy)
@@ -62,6 +62,7 @@
#include <boost/bind.hpp>
#include <boost/filesystem/operations.hpp>
+#include <algorithm>
#include <iostream>
#include <csignal>
#include <map>
@@ -552,6 +553,17 @@
}
+void LyX::addFileToLoad(FileName const & fname)
+{
+ vector<FileName>::const_iterator cit = std::find(
+ pimpl_->files_to_load_.begin(), pimpl_->files_to_load_.end(),
+ fname);
+
+ if (cit == pimpl_->files_to_load_.end())
+ pimpl_->files_to_load_.push_back(fname);
+}
+
+
void LyX::loadFiles()
{
vector<FileName>::const_iterator it = pimpl_->files_to_load_.begin();
Index: LyX.h
===================================================================
--- LyX.h (revision 18191)
+++ LyX.h (working copy)
@@ -21,6 +21,10 @@
namespace lyx {
+namespace support {
+class FileName;
+}
+
class Buffer;
class BufferList;
class Converters;
@@ -102,6 +106,9 @@
/// Execute batch commands if available.
void execBatchCommands();
+ ///
+ void addFileToLoad(support::FileName const &);
+
private:
/// Do some cleanup in preparation of an exit.
void prepareExit();