GuiView * gv = currentView();
if (gv && gv->currentBufferView())
// cancel any selection
- lyx::dispatch(FuncRequest(LFUN_MARK_OFF));
+ processFuncRequest(FuncRequest(LFUN_MARK_OFF));
dr.setMessage(from_ascii(N_("Cancel")));
break;
}
if (func.action() == LFUN_SELF_INSERT) {
if (encoded_last_key != 0) {
docstring const arg(1, encoded_last_key);
- lyx::dispatch(FuncRequest(LFUN_SELF_INSERT, arg,
+ processFuncRequest(FuncRequest(LFUN_SELF_INSERT, arg,
FuncRequest::KEYBOARD));
LYXERR(Debug::KEY, "SelfInsert arg[`" << to_utf8(arg) << "']");
}
} else
- lyx::dispatch(func);
+ processFuncRequest(func);
}
-void GuiApplication::dispatchDelayed(FuncRequest const & func)
+void GuiApplication::processFuncRequest(FuncRequest const & func)
{
- addtoFuncRequestQueue(func);
+ lyx::dispatch(func);
+}
+
+
+void GuiApplication::processFuncRequestAsync(FuncRequest const & func)
+{
+ addToFuncRequestQueue(func);
processFuncRequestQueueAsync();
}
-void GuiApplication::addtoFuncRequestQueue(FuncRequest const & func)
+void GuiApplication::processFuncRequestQueue()
{
- d->func_request_queue_.push(func);
+ while (!d->func_request_queue_.empty()) {
+ processFuncRequest(d->func_request_queue_.front());
+ d->func_request_queue_.pop();
+ }
}
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()));
+ QTimer::singleShot(0, this, SLOT(slotProcessFuncRequestQueue()));
+}
+
+
+void GuiApplication::addToFuncRequestQueue(FuncRequest const & func)
+{
+ d->func_request_queue_.push(func);
}
gv->resetDialogs();
}
- lyx::dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
+ processFuncRequest(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
}
}
-void GuiApplication::processFuncRequestQueue()
-{
- while (!d->func_request_queue_.empty()) {
- lyx::dispatch(d->func_request_queue_.front());
- d->func_request_queue_.pop();
- }
-}
-
-
void GuiApplication::execBatchCommands()
{
setGuiLanguage();
// commands are not executed here yet and the gui is not ready
// therefore.
QFileOpenEvent * foe = static_cast<QFileOpenEvent *>(e);
- dispatchDelayed(FuncRequest(LFUN_FILE_OPEN, qstring_to_ucs4(foe->file())));
+ FuncRequest const fr(LFUN_FILE_OPEN, qstring_to_ucs4(foe->file()));
+ processFuncRequestAsync(fr);
e->accept();
return true;
}
/// 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
+ /// \name Methods to process FuncRequests
+ //@{
+ /// process the func request
+ void processFuncRequest(FuncRequest const &);
+ /// add a func request to the queue and process it asynchronously
+ /// \note As a side-effect this will also process the
+ /// func requests that were added to the queue before.
+ void processFuncRequestAsync(FuncRequest const &);
+ /// process the func requests in the queue
+ void processFuncRequestQueue();
+ /// process the func requests in the queue asynchronously
void processFuncRequestQueueAsync();
+ /// add a func request to the queue for later processing
+ void addToFuncRequestQueue(FuncRequest const &);
+ //@}
/// goto a bookmark
/// openFile: whether or not open a file if the file is not opened
///
void onLastWindowClosed();
///
- void processFuncRequestQueue();
+ void slotProcessFuncRequestQueue() { processFuncRequestQueue(); }
private:
///
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
cmd = FuncRequest(LFUN_FILE_OPEN, file);
}
// add the functions to the queue
- guiApp->addtoFuncRequestQueue(cmd);
+ guiApp->addToFuncRequestQueue(cmd);
event->accept();
}
- // now process the collected functions
+ // now process the collected functions. We perform the events
+ // asynchronously. This prevents potential problems in case the
+ // BufferView is closed within an event.
guiApp->processFuncRequestQueueAsync();
}