return fmts;
}
-
+
+
+class FuncRequestEvent : public QEvent
+{
+public:
+ FuncRequestEvent(FuncRequest const & req)
+ : QEvent(QEvent::User), request(req) {}
+
+ FuncRequest const request;
+};
+
+
////////////////////////////////////////////////////////////////////////
// Icon loading support code.
////////////////////////////////////////////////////////////////////////
int GuiApplication::exec()
{
- QTimer::singleShot(1, this, SLOT(execBatchCommands()));
+ // asynchronously handle batch commands. This event will be in
+ // the event queue in front of other asynchronous events. Hence,
+ // we can assume in the latter that the gui is setup already.
+ QTimer::singleShot(0, this, SLOT(execBatchCommands()));
+
return QApplication::exec();
}
}
+void GuiApplication::customEvent(QEvent * event)
+{
+ FuncRequestEvent * reqEv = static_cast<FuncRequestEvent *>(event);
+ lyx::dispatch(reqEv->request);
+}
+
+
bool GuiApplication::event(QEvent * e)
{
switch(e->type()) {
case QEvent::FileOpen: {
- // Open a file; this happens only on Mac OS X for now
+ // Open a file; this happens only on Mac OS X for now.
+ //
+ // We do this asynchronously because on startup the batch
+ // commands are not executed here yet and the gui is not ready
+ // therefore.
QFileOpenEvent * foe = static_cast<QFileOpenEvent *>(e);
- lyx::dispatch(FuncRequest(LFUN_FILE_OPEN,
- qstring_to_ucs4(foe->file())));
+ postEvent(this, new FuncRequestEvent(FuncRequest(LFUN_FILE_OPEN,
+ qstring_to_ucs4(foe->file()))));
e->accept();
return true;
}
return;
}
- // No session handling, default to a sane size.
+ // no session handling, default to a sane size.
setGeometry(50, 50, 690, 510);
initToolbars();
- // This enables to clear session data if any.
+
+ // clear session data if any.
QSettings settings;
settings.remove("views");
}