]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiAlert.cpp
On Linux show in crash message box the backtrace
[lyx.git] / src / frontends / qt4 / GuiAlert.cpp
index a7bb480094f28b8547eee97a2d18a69a31b6ba52..14cce933e478bef4548b202a94c30b01071c5c41 100644 (file)
@@ -24,6 +24,7 @@
 #include "support/debug.h"
 #include "support/docstring.h"
 #include "support/lstrings.h"
+#include "support/lassert.h"
 #include "support/ProgressInterface.h"
 
 #include <QApplication>
@@ -92,6 +93,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 +122,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;
@@ -153,6 +162,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);
 
@@ -168,6 +182,9 @@ void doWarning(docstring const & title0, docstring const & message,
        }
 
        qApp->restoreOverrideCursor();
+
+       if (long_op)
+               theApp()->startLongOperation();
 }
 
 void warning(docstring const & title0, docstring const & message,
@@ -181,12 +198,17 @@ void warning(docstring const & title0, docstring const & message,
                                title0, message, askshowagain);
 }
 
-void doError(docstring const & title0, docstring const & message)
+void doError(docstring const & title0, docstring const & message, bool backtrace)
 {
        lyxerr << "Error: " << title0 << '\n'
               << "----------------------------------------\n"
               << message << endl;
 
+       QString details;
+       if (backtrace) {
+               details = QString::fromLocal8Bit(to_local8bit(printCallStack()).c_str());
+       }
+
        if (!use_gui)
                return;
 
@@ -197,24 +219,33 @@ 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);
 
        ProgressInterface::instance()->error(
                toqstr(title),
-               toqstr(message));
+               toqstr(message),
+               details);
 
        qApp->restoreOverrideCursor();
+
+       if (long_op)
+               theApp()->startLongOperation();
 }
 
-void error(docstring const & title0, docstring const & message)
+void error(docstring const & title0, docstring const & message, bool backtrace)
 {
 #ifdef EXPORT_in_THREAD
        InGuiThread<void>().call(&doError, 
 #else
        doError(
 #endif
-                               title0, message);
+                               title0, message, backtrace);
 }
 
 void doInformation(docstring const & title0, docstring const & message)
@@ -234,6 +265,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);
 
@@ -242,6 +278,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)
@@ -270,6 +309,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),
@@ -277,6 +321,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;