From eef602cc9ebad680028f2ff61c23afcb2a0609ca Mon Sep 17 00:00:00 2001 From: Tommaso Cucinotta Date: Sun, 9 Mar 2014 15:40:13 +0000 Subject: [PATCH] Prevent LyX from freezing in additional common cases where it would 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/frontends/qt4/GuiAlert.cpp b/src/frontends/qt4/GuiAlert.cpp index 0113389a9a..4e9a8e4c2a 100644 --- a/src/frontends/qt4/GuiAlert.cpp +++ b/src/frontends/qt4/GuiAlert.cpp @@ -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; -- 2.39.2