]> git.lyx.org Git - features.git/commitdiff
move calls to Buffer::errors and Buffer::message to GUI thread
authorPeter Kümmel <syntheticpp@gmx.net>
Mon, 21 Dec 2009 13:11:17 +0000 (13:11 +0000)
committerPeter Kümmel <syntheticpp@gmx.net>
Mon, 21 Dec 2009 13:11:17 +0000 (13:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32606 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/frontends/qt4/GuiProgress.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h

index 6da2e91de7b16061ea5412fad1abc3defd1f9cc5..9768b4800948c9d8c9df1e32cb4e02f032d061a9 100644 (file)
@@ -350,7 +350,7 @@ Buffer::~Buffer()
        if (!isClean()) {
                docstring msg = _("LyX attempted to close a document that had unsaved changes!\n");
                msg += emergencyWrite();
-               frontend::Alert::warning(_("Attempting to close changed document!"), msg);
+               Alert::warning(_("Attempting to close changed document!"), msg);
        }
                
        // clear references to children in macro tables
index c6c5506bd07d222a6621ff5f6dea1caf38210741..35bcb0e23f29b6d91203c3cb0ae8be46845d88d7 100644 (file)
@@ -97,7 +97,7 @@ void GuiProgress::doClearMessages()
 
 void GuiProgress::appendText(QString const & text)
 {
-       view_->message(qstring_to_ucs4(text));
+       view_->updateMessage(text);
 }
 
 
index 373e015c6b7ca9e52209178efb29e20bb90f0215..57339ee1d1380796c7710a42a7ba2a228744b00d 100644 (file)
@@ -193,7 +193,7 @@ struct GuiView::GuiViewPrivate
                stack_widget_->addWidget(bg_widget_);
                stack_widget_->addWidget(splitter_);
                setBackground();
-               progress = new GuiProgress(gv);
+               progress_ = new GuiProgress(gv);
        }
 
        ~GuiViewPrivate()
@@ -201,7 +201,7 @@ struct GuiView::GuiViewPrivate
                delete splitter_;
                delete bg_widget_;
                delete stack_widget_;
-               delete progress;
+               delete progress_;
        }
 
        QMenu * toolBarPopup(GuiView * parent)
@@ -287,7 +287,7 @@ public:
        BackgroundWidget * bg_widget_;
        /// view's toolbars
        ToolbarMap toolbars_;
-       GuiProgress* progress;
+       ProgressInterface* progress_;
        /// The main layout box.
        /** 
         * \warning Don't Delete! The layout box is actually owned by
@@ -385,6 +385,9 @@ GuiView::GuiView(int id)
        connect(&d.autosave_watcher_, SIGNAL(finished()), this,
                SLOT(threadFinished()));
 #endif
+
+ connect(this, SIGNAL(triggerShowDialog(QString const &, QString const &, Inset *)),
+               SLOT(doShowDialog(QString const &, QString const &, Inset *)));
 }
 
 
@@ -697,8 +700,15 @@ void GuiView::message(docstring const & str)
 {
        if (ForkedProcess::iAmAChild())
                return;
+       
+       // call is moved to GUI-thread by GuiProgress
+       d.progress_->appendMessage(toqstr(str));
+}
 
-       statusBar()->showMessage(toqstr(str));
+
+void GuiView::updateMessage(QString const & str)
+{
+       statusBar()->showMessage(str);
        d.statusbar_timer_.stop();
        d.statusbar_timer_.start(3000);
 }
@@ -3250,10 +3260,20 @@ Dialog * GuiView::findOrBuild(string const & name, bool hide_it)
 
 void GuiView::showDialog(string const & name, string const & data,
        Inset * inset)
+{
+       triggerShowDialog(toqstr(name), toqstr(data), inset);
+}
+
+
+void GuiView::doShowDialog(QString const & qname, QString const & qdata,
+       Inset * inset)
 {
        if (d.in_show_)
                return;
 
+       const string name = fromqstr(qname);
+       const string data = fromqstr(qdata);
+
        d.in_show_ = true;
        try {
                Dialog * dialog = findOrBuild(name, false);
index 02bb82dfb9d136d67c7043c45ed19275470b561f..44d491e80cc12dc990dc9f0c17bfc16bd9d384f9 100644 (file)
@@ -72,7 +72,12 @@ public:
        BufferView const * documentBufferView() const;
        void newDocument(std::string const & filename,
                bool fromTemplate);
+
+       /// could be called from any thread
        void message(docstring const &);
+       /// must be called from GUI thread
+       void updateMessage(QString const & str);
+
        bool getStatus(FuncRequest const & cmd, FuncStatus & flag);
        bool dispatch(FuncRequest const & cmd);
        void restartCursor();
@@ -158,6 +163,7 @@ public:
 
 Q_SIGNALS:
        void closing(int);
+       void triggerShowDialog(QString const & qname, QString const & qdata, Inset * inset);
 
 public Q_SLOTS:
        /// idle timeout.
@@ -183,6 +189,10 @@ private Q_SLOTS:
        /// For completion of autosave or exporrt threads.
        void threadFinished();
 
+       /// must be called in GUI thread
+       void doShowDialog(QString const & qname, QString const & qdata,
+       Inset * inset);
+
 private:
        /// Open given child document in current buffer directory.
        void openChildDocument(std::string const & filename);
@@ -243,7 +253,8 @@ public:
         */
        void updateDialogs();
 
-       /** \param name == "bibtex", "citation" etc; an identifier used to
+       /** Show dialog could be called from arbitrary threads.
+           \param name == "bibtex", "citation" etc; an identifier used to
            launch a particular dialog.
            \param data is a string representation of the Inset contents.
            It is often little more than the output from Inset::write.