The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit 0f97ae5480498b8fcf43344542d8896cea864570
Author: Tommaso Cucinotta <tomm...@lyx.org>
Date:   Sun Jul 1 08:27:11 2012 +0100

    Avoid that, if an error dialog pops up during a long operation, it freezes 
LyX.

diff --git a/src/frontends/Application.h b/src/frontends/Application.h
index 0bba5ce..0609f90 100644
--- a/src/frontends/Application.h
+++ b/src/frontends/Application.h
@@ -246,6 +246,8 @@ public:
        virtual bool longOperationCancelled() = 0;
        /// Stop the long operation mode (i.e., release the GUI)
        virtual void stopLongOperation() = 0;
+       /// A started long operation is still in progress ?
+       virtual bool longOperationStarted() = 0;
 
 };
 
diff --git a/src/frontends/qt4/GuiAlert.cpp b/src/frontends/qt4/GuiAlert.cpp
index a7bb480..0113389 100644
--- a/src/frontends/qt4/GuiAlert.cpp
+++ b/src/frontends/qt4/GuiAlert.cpp
@@ -92,6 +92,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 +121,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;
@@ -197,6 +205,11 @@ 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);
 
@@ -205,6 +218,9 @@ void doError(docstring const & title0, docstring const & 
message)
                toqstr(message));
 
        qApp->restoreOverrideCursor();
+
+       if (long_op)
+               theApp()->startLongOperation();
 }
 
 void error(docstring const & title0, docstring const & message)
diff --git a/src/frontends/qt4/GuiApplication.cpp 
b/src/frontends/qt4/GuiApplication.cpp
index 94581a3..701b488 100644
--- a/src/frontends/qt4/GuiApplication.cpp
+++ b/src/frontends/qt4/GuiApplication.cpp
@@ -684,6 +684,7 @@ public:
 class KeyChecker : public QObject {
 private:
        bool pressed_;
+       bool started_;
 public:
        KeyChecker() {
                pressed_ = false;
@@ -691,14 +692,19 @@ public:
        void start() {
                QCoreApplication::instance()->installEventFilter(this);
                pressed_ = false;
+               started_ = true;
        }
        void stop() {
                QCoreApplication::instance()->removeEventFilter(this);
+               started_ = false;
        }
        bool pressed() {
                QCoreApplication::processEvents();
                return pressed_;
        }
+       bool started() const {
+               return started_;
+       }
        bool eventFilter(QObject *obj, QEvent *event) {
                LYXERR(Debug::ACTION, "Event Type: " << event->type());
                switch (event->type()) {
@@ -2679,6 +2685,11 @@ void GuiApplication::stopLongOperation() {
 }
 
 
+bool GuiApplication::longOperationStarted() {
+       return d->key_checker_.started();
+}
+
+
 ////////////////////////////////////////////////////////////////////////
 //
 // X11 specific stuff goes here...
diff --git a/src/frontends/qt4/GuiApplication.h 
b/src/frontends/qt4/GuiApplication.h
index 7691452..57b3783 100644
--- a/src/frontends/qt4/GuiApplication.h
+++ b/src/frontends/qt4/GuiApplication.h
@@ -175,7 +175,8 @@ public:
        bool longOperationCancelled();
        /// Stop the long operation mode (i.e., release the GUI)
        void stopLongOperation();
-
+       /// A started long operation is still in progress ?
+       bool longOperationStarted();
 private Q_SLOTS:
        ///
        void execBatchCommands();

-----------------------------------------------------------------------

Summary of changes:
 src/frontends/Application.h          |    2 ++
 src/frontends/qt4/GuiAlert.cpp       |   16 ++++++++++++++++
 src/frontends/qt4/GuiApplication.cpp |   11 +++++++++++
 src/frontends/qt4/GuiApplication.h   |    3 ++-
 4 files changed, 31 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to