void GuiApplication::dispatchDelayed(FuncRequest const & func)
+{
+ addtoFuncRequestQueue(func);
+ processFuncRequestQueueAsync();
+}
+
+
+void GuiApplication::addtoFuncRequestQueue(FuncRequest const & func)
{
d->func_request_queue_.push(func);
+}
+
+
+void GuiApplication::processFuncRequestQueueAsync()
+{
+ // We perform the events asynchronously. This prevents potential
+ // problems in case the BufferView is closed within an event.
QTimer::singleShot(0, this, SLOT(processFuncRequestQueue()));
}
void GuiApplication::processFuncRequestQueue()
{
while (!d->func_request_queue_.empty()) {
- lyx::dispatch(d->func_request_queue_.back());
+ lyx::dispatch(d->func_request_queue_.front());
d->func_request_queue_.pop();
}
}
void dispatch(FuncRequest const &);
void dispatch(FuncRequest const &, DispatchResult & dr);
FuncStatus getStatus(FuncRequest const & cmd) const;
- void dispatchDelayed(FuncRequest const &);
void restoreGuiSession();
Clipboard & clipboard();
Selection & selection();
/// return the status bar state string
docstring viewStatusMessage();
+ /// add a func request to the queue for later procession
+ void addtoFuncRequestQueue(FuncRequest const &);
+ /// process the func request in the queue asynchronously
+ void processFuncRequestQueueAsync();
+
/// goto a bookmark
/// openFile: whether or not open a file if the file is not opened
/// switchToBuffer: whether or not switch to buffer if the buffer is
void setGuiLanguage();
///
void reconfigure(std::string const & option);
+ /// add a func request to the queue and process it asynchronously
+ void dispatchDelayed(FuncRequest const &);
/// This GuiView is the one receiving Clipboard and Selection
/// events
"No formats found, trying to open it as a lyx file");
cmd = FuncRequest(LFUN_FILE_OPEN, file);
}
-
- // Asynchronously post the event. DropEvent usually comes
- // from the BufferView. But reloading a file might close
- // the BufferView from within its own event handler.
- guiApp->dispatchDelayed(cmd);
+ // add the functions to the queue
+ guiApp->addtoFuncRequestQueue(cmd);
event->accept();
}
+ // now process the collected functions
+ guiApp->processFuncRequestQueueAsync();
}