]> git.lyx.org Git - features.git/commitdiff
Fix bug 6944: crash on drag and drop multiple files
authorJürgen Spitzmüller <spitz@lyx.org>
Fri, 22 Oct 2010 15:46:46 +0000 (15:46 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Fri, 22 Oct 2010 15:46:46 +0000 (15:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35779 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
src/frontends/qt4/GuiView.cpp

index 571e30c9d6c0a25f1e5bd5ff461949cc16c2b557..dcce91565bb79bf0300cb68be9248cc74d5521b9 100644 (file)
@@ -1786,8 +1786,22 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
 
 
 void GuiApplication::dispatchDelayed(FuncRequest const & func)
+{
+       addtoFuncRequestQueue(func);
+       processFuncRequestQueueAsync();
+}
+
+
+void GuiApplication::addtoFuncRequestQueue(FuncRequest const & func)
 {
        d->func_request_queue_.push(func);
+}
+
+
+void GuiApplication::processFuncRequestQueueAsync()
+{
+       // We perform the events asynchronously. This prevents potential
+       // problems in case the BufferView is closed within an event.
        QTimer::singleShot(0, this, SLOT(processFuncRequestQueue()));
 }
 
@@ -1976,7 +1990,7 @@ void GuiApplication::setGuiLanguage()
 void GuiApplication::processFuncRequestQueue()
 {
        while (!d->func_request_queue_.empty()) {
-               lyx::dispatch(d->func_request_queue_.back());
+               lyx::dispatch(d->func_request_queue_.front());
                d->func_request_queue_.pop();
        }
 }
index 386b270027680cd7b55b8780129c450e9874ffd6..813d1caf83b7970652dc39034c5224240bd062c0 100644 (file)
@@ -60,7 +60,6 @@ public:
        void dispatch(FuncRequest const &);
        void dispatch(FuncRequest const &, DispatchResult & dr);
        FuncStatus getStatus(FuncRequest const & cmd) const;
-       void dispatchDelayed(FuncRequest const &);
        void restoreGuiSession();
        Clipboard & clipboard();
        Selection & selection();
@@ -136,6 +135,11 @@ public:
        /// return the status bar state string
        docstring viewStatusMessage();
 
+       /// add a func request to the queue for later procession
+       void addtoFuncRequestQueue(FuncRequest const &);
+       /// process the func request in the queue asynchronously
+       void processFuncRequestQueueAsync();
+
        /// goto a bookmark
        /// openFile: whether or not open a file if the file is not opened
        /// switchToBuffer: whether or not switch to buffer if the buffer is
@@ -164,6 +168,8 @@ private:
        void setGuiLanguage();
        ///
        void reconfigure(std::string const & option);
+       /// add a func request to the queue and process it asynchronously
+       void dispatchDelayed(FuncRequest const &);
 
        /// This GuiView is the one receiving Clipboard and Selection
        /// events
index e24ec9703e35dd96559a88d88ed303672de90bea..10e461a4b71b1fb4ddf2e0c4a635b76e47f9ae1b 100644 (file)
@@ -794,13 +794,12 @@ void GuiView::dropEvent(QDropEvent * event)
                                "No formats found, trying to open it as a lyx file");
                        cmd = FuncRequest(LFUN_FILE_OPEN, file);
                }
-
-               // Asynchronously post the event. DropEvent usually comes
-               // from the BufferView. But reloading a file might close
-               // the BufferView from within its own event handler.
-               guiApp->dispatchDelayed(cmd);
+               // add the functions to the queue
+               guiApp->addtoFuncRequestQueue(cmd);
                event->accept();
        }
+       // now process the collected functions
+       guiApp->processFuncRequestQueueAsync();
 }