]> 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 0113389a9ab4ab68f20d77eeb960ba35999c81cd..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>
@@ -161,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);
 
@@ -176,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,
@@ -189,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;
 
@@ -215,7 +229,8 @@ void doError(docstring const & title0, docstring const & message)
 
        ProgressInterface::instance()->error(
                toqstr(title),
-               toqstr(message));
+               toqstr(message),
+               details);
 
        qApp->restoreOverrideCursor();
 
@@ -223,14 +238,14 @@ void doError(docstring const & title0, docstring const & message)
                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)
@@ -250,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);
 
@@ -258,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)
@@ -286,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),
@@ -293,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;