From 8265a72ffc4629fde76928773cffbca1db07e2dd Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 25 Sep 2015 11:57:12 +0300 Subject: [PATCH] Improve viewer performance --- src/XGUI/XGUI_Displayer.cpp | 9 +++++++-- src/XGUI/XGUI_Displayer.h | 7 ++++++- src/XGUI/XGUI_WorkshopListener.cpp | 1 - 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index b41682090..4ddd90572 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -96,7 +96,7 @@ QString qIntListInfo(const QIntList& theValues, const QString& theSeparator = QS } XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop) - : myWorkshop(theWorkshop), myEnableUpdateViewer(true) + : myWorkshop(theWorkshop), myEnableUpdateViewer(true), myNeedUpdate(false) { enableUpdateViewer(true); myCustomPrs = std::shared_ptr(new XGUI_CustomPrs()); @@ -689,7 +689,10 @@ bool XGUI_Displayer::enableUpdateViewer(const bool isEnabled) bool aWasEnabled = myEnableUpdateViewer; myEnableUpdateViewer = isEnabled; - + if (myNeedUpdate && myEnableUpdateViewer) { + updateViewer(); + myNeedUpdate = false; + } return aWasEnabled; } @@ -700,6 +703,8 @@ void XGUI_Displayer::updateViewer() const if (!aContext.IsNull() && myEnableUpdateViewer) { myWorkshop->viewer()->Zfitall(); aContext->UpdateCurrentViewer(); + } else { + myNeedUpdate = true; } } diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h index b189189f6..3cd6f9c73 100644 --- a/src/XGUI/XGUI_Displayer.h +++ b/src/XGUI/XGUI_Displayer.h @@ -141,6 +141,8 @@ class XGUI_EXPORT XGUI_Displayer: public QObject /// \param isEnabled a boolean value bool enableUpdateViewer(const bool isEnabled); + bool isUpdateEnabled() const { return myEnableUpdateViewer; } + /// Updates the viewer void updateViewer() const; @@ -307,7 +309,10 @@ private: QIntList myActiveSelectionModes; /// the enable update viewer flag - bool myEnableUpdateViewer; + bool myEnableUpdateViewer; + + /// A flag that update was requested but not done + mutable bool myNeedUpdate; }; #endif diff --git a/src/XGUI/XGUI_WorkshopListener.cpp b/src/XGUI/XGUI_WorkshopListener.cpp index 434b6cdd8..e5c95c78b 100755 --- a/src/XGUI/XGUI_WorkshopListener.cpp +++ b/src/XGUI/XGUI_WorkshopListener.cpp @@ -191,7 +191,6 @@ void XGUI_WorkshopListener::processEvent(const std::shared_ptr& // the viewer's update context is unblocked, the viewer's update works XGUI_Displayer* aDisplayer = workshop()->displayer(); aDisplayer->enableUpdateViewer(true); - aDisplayer->updateViewer(); } else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)) { std::shared_ptr aUpdMsg = std::dynamic_pointer_cast(theMessage); -- 2.39.2