#include <boost/bind.hpp>
#include <boost/filesystem/operations.hpp>
+#include <algorithm>
#include <iostream>
#include <csignal>
#include <map>
}
+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();
namespace lyx {
+namespace support {
+class FileName;
+}
+
class Buffer;
class BufferList;
class Converters;
/// Execute batch commands if available.
void execBatchCommands();
+ ///
+ void addFileToLoad(support::FileName const &);
+
private:
/// Do some cleanup in preparation of an exit.
void prepareExit();
#include "graphics/LoaderQueue.h"
+#include "support/FileName.h"
#include "support/lstrings.h"
#include "support/os.h"
#include "support/Package.h"
namespace lyx {
+using support::FileName;
+
frontend::Application * createApplication(int & argc, char * argv[])
{
return new frontend::GuiApplication(argc, argv);
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: