]> git.lyx.org Git - features.git/commitdiff
Prevent LyX from freezing in additional common cases where it would
authorTommaso Cucinotta <tommaso@lyx.org>
Sun, 9 Mar 2014 15:40:13 +0000 (15:40 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Sun, 9 Mar 2014 15:43:58 +0000 (15:43 +0000)
try to show dialogs or ask for user input while doing advanced find
and replace. In many of these cases we should simply find a way for
avoiding lyx to show a dialog, however an extra info/warning dialog
is better than the GUI freezing and having to kill the process.

src/frontends/qt4/GuiAlert.cpp

index 0113389a9ab4ab68f20d77eeb960ba35999c81cd..4e9a8e4c2a6055229c4d331b65b394311125ca13 100644 (file)
@@ -161,6 +161,11 @@ void doWarning(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);
 
@@ -176,6 +181,9 @@ void doWarning(docstring const & title0, docstring const & message,
        }
 
        qApp->restoreOverrideCursor();
+
+       if (long_op)
+               theApp()->startLongOperation();
 }
 
 void warning(docstring const & title0, docstring const & message,
@@ -250,6 +258,11 @@ void doInformation(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);
 
@@ -258,6 +271,9 @@ void doInformation(docstring const & title0, docstring const & message)
                toqstr(message));
 
        qApp->restoreOverrideCursor();
+
+       if (long_op)
+               theApp()->startLongOperation();
 }
 
 void information(docstring const & title0, docstring const & message)
@@ -286,6 +302,11 @@ bool doAskForText(docstring & response, docstring const & msg,
 
        docstring const title = bformat(_("LyX: %1$s"), msg);
 
+       /// Long operation in progress prevents user from Ok-ing the error dialog
+       bool long_op = theApp()->longOperationStarted();
+       if (long_op)
+               theApp()->stopLongOperation();
+
        bool ok;
        QString text = QInputDialog::getText(qApp->focusWidget(),
                toqstr(title),
@@ -293,6 +314,9 @@ bool doAskForText(docstring & response, docstring const & msg,
                QLineEdit::Normal,
                toqstr(dflt), &ok);
 
+       if (long_op)
+               theApp()->startLongOperation();
+
        if (ok) {
                response = qstring_to_ucs4(text);
                return true;