From 30a4203f4a2b9697397ae33c1637456c29751f4a Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Sat, 19 Dec 2009 12:24:44 +0000 Subject: [PATCH] GuiView: reconnect the QFutureWatcher each time the QFuture is changed. This enable to send the result properly. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@32586 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiView.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 435db42f29..c0230751d5 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -175,8 +175,8 @@ typedef boost::shared_ptr DialogPtr; struct GuiView::GuiViewPrivate { - GuiViewPrivate() - : current_work_area_(0), current_main_work_area_(0), + GuiViewPrivate(GuiView * gv) + : gv_(gv), current_work_area_(0), current_main_work_area_(0), layout_(0), autosave_timeout_(5000), in_show_(false) { @@ -265,7 +265,15 @@ struct GuiView::GuiViewPrivate return tabWorkArea(0); } + void setPreviewFuture(QFuture const & f) + { + preview_watcher_.setFuture(f); + connect(&preview_watcher_, SIGNAL(finished()), gv_, + SLOT(threadFinished())); + } + public: + GuiView * gv_; GuiWorkArea * current_work_area_; GuiWorkArea * current_main_work_area_; QSplitter * splitter_; @@ -309,7 +317,7 @@ public: GuiView::GuiView(int id) - : d(*new GuiViewPrivate), id_(id), closing_(false) + : d(*new GuiViewPrivate(this)), id_(id), closing_(false) { // GuiToolbars *must* be initialised before the menu bar. normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge @@ -369,8 +377,6 @@ GuiView::GuiView(int id) #if (QT_VERSION >= 0x040400) connect(&d.autosave_watcher_, SIGNAL(finished()), this, SLOT(threadFinished())); - connect(&d.preview_watcher_, SIGNAL(finished()), this, - SLOT(threadFinished())); #endif } @@ -2682,7 +2688,7 @@ bool GuiView::dispatch(FuncRequest const & cmd) #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400) QFuture f = QtConcurrent::run(exportAndDestroy, doc_buffer->clone(), cmd.argument()); - d.preview_watcher_.setFuture(f); + d.setPreviewFuture(f); #else doc_buffer->doExport(format, true); #endif @@ -2697,7 +2703,7 @@ bool GuiView::dispatch(FuncRequest const & cmd) #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400) QFuture f = QtConcurrent::run(previewAndDestroy, doc_buffer->clone(), cmd.argument()); - d.preview_watcher_.setFuture(f); + d.setPreviewFuture(f); #else doc_buffer->preview(format); #endif @@ -2713,7 +2719,7 @@ bool GuiView::dispatch(FuncRequest const & cmd) #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400) QFuture f = QtConcurrent::run(exportAndDestroy, master->clone(), cmd.argument()); - d.preview_watcher_.setFuture(f); + d.setPreviewFuture(f); #else master->doExport(format, true); #endif @@ -2727,7 +2733,7 @@ bool GuiView::dispatch(FuncRequest const & cmd) #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400) QFuture f = QtConcurrent::run(previewAndDestroy, master->clone(), cmd.argument()); - d.preview_watcher_.setFuture(f); + d.setPreviewFuture(f); #else master->preview(format); #endif