[LyX/master] 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 simpl

2014-03-09 Thread Tommaso Cucinotta
commit eef602cc9ebad680028f2ff61c23afcb2a0609ca
Author: Tommaso Cucinotta tomm...@lyx.org
Date:   Sun Mar 9 15:40:13 2014 +

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.

diff --git a/src/frontends/qt4/GuiAlert.cpp b/src/frontends/qt4/GuiAlert.cpp
index 0113389..4e9a8e4 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;


[LyX/master] 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 simpl

2014-03-09 Thread Tommaso Cucinotta
commit eef602cc9ebad680028f2ff61c23afcb2a0609ca
Author: Tommaso Cucinotta 
Date:   Sun Mar 9 15:40:13 2014 +

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.

diff --git a/src/frontends/qt4/GuiAlert.cpp b/src/frontends/qt4/GuiAlert.cpp
index 0113389..4e9a8e4 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), );
 
+   if (long_op)
+   theApp()->startLongOperation();
+
if (ok) {
response = qstring_to_ucs4(text);
return true;