diff --git a/src/frontends/Application.h b/src/frontends/Application.h index 0bba5cea55..0609f90396 100644 --- a/src/frontends/Application.h +++ b/src/frontends/Application.h @@ -246,6 +246,8 @@ public: virtual bool longOperationCancelled() = 0; /// Stop the long operation mode (i.e., release the GUI) virtual void stopLongOperation() = 0; + /// A started long operation is still in progress ? + virtual bool longOperationStarted() = 0; }; diff --git a/src/frontends/qt4/GuiAlert.cpp b/src/frontends/qt4/GuiAlert.cpp index a7bb480094..0113389a9a 100644 --- a/src/frontends/qt4/GuiAlert.cpp +++ b/src/frontends/qt4/GuiAlert.cpp @@ -92,6 +92,11 @@ int doPrompt(docstring const & title0, docstring const & question, docstring const title = bformat(_("LyX: %1$s"), title0); + /// Long operation in progress prevents user from Ok-ing the error dialog + bool long_op = theApp()->longOperationStarted(); + if (long_op) + theApp()->stopLongOperation(); + // For some reason, sometimes Qt uses a hourglass or watch cursor when // displaying the alert. Hence, we ask for the standard cursor shape. qApp->setOverrideCursor(Qt::ArrowCursor); @@ -116,6 +121,9 @@ int doPrompt(docstring const & title0, docstring const & question, qApp->restoreOverrideCursor(); + if (long_op) + theApp()->startLongOperation(); + // Qt bug: can return -1 on cancel or WM close, despite the docs. if (res == -1) res = cancel_button; @@ -197,6 +205,11 @@ void doError(docstring const & title0, docstring const & message) return; } + /// Long operation in progress prevents user from Ok-ing the error dialog + bool long_op = theApp()->longOperationStarted(); + if (long_op) + theApp()->stopLongOperation(); + // Don't use a hourglass cursor while displaying the alert qApp->setOverrideCursor(Qt::ArrowCursor); @@ -205,6 +218,9 @@ void doError(docstring const & title0, docstring const & message) toqstr(message)); qApp->restoreOverrideCursor(); + + if (long_op) + theApp()->startLongOperation(); } void error(docstring const & title0, docstring const & message) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 94581a3795..701b488eab 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -684,6 +684,7 @@ public: class KeyChecker : public QObject { private: bool pressed_; + bool started_; public: KeyChecker() { pressed_ = false; @@ -691,14 +692,19 @@ public: void start() { QCoreApplication::instance()->installEventFilter(this); pressed_ = false; + started_ = true; } void stop() { QCoreApplication::instance()->removeEventFilter(this); + started_ = false; } bool pressed() { QCoreApplication::processEvents(); return pressed_; } + bool started() const { + return started_; + } bool eventFilter(QObject *obj, QEvent *event) { LYXERR(Debug::ACTION, "Event Type: " << event->type()); switch (event->type()) { @@ -2679,6 +2685,11 @@ void GuiApplication::stopLongOperation() { } +bool GuiApplication::longOperationStarted() { + return d->key_checker_.started(); +} + + //////////////////////////////////////////////////////////////////////// // // X11 specific stuff goes here... diff --git a/src/frontends/qt4/GuiApplication.h b/src/frontends/qt4/GuiApplication.h index 7691452881..57b37836c6 100644 --- a/src/frontends/qt4/GuiApplication.h +++ b/src/frontends/qt4/GuiApplication.h @@ -175,7 +175,8 @@ public: bool longOperationCancelled(); /// Stop the long operation mode (i.e., release the GUI) void stopLongOperation(); - + /// A started long operation is still in progress ? + bool longOperationStarted(); private Q_SLOTS: /// void execBatchCommands();