diff --git a/Qt/ApplicationComponents/pqExampleVisualizationsDialog.cxx b/Qt/ApplicationComponents/pqExampleVisualizationsDialog.cxx index c90439bdd3053fe940508d5ad954f829a8f38e45..c1f435d44bc1ae345595bc5bfe83dd6d9ce9df31 100644 --- a/Qt/ApplicationComponents/pqExampleVisualizationsDialog.cxx +++ b/Qt/ApplicationComponents/pqExampleVisualizationsDialog.cxx @@ -4,6 +4,7 @@ #include "pqActiveObjects.h" #include "pqApplicationCore.h" #include "pqEventDispatcher.h" +#include "pqLoadStateReaction.h" #include "vtkPVConfig.h" #include "vtkPVFileInformation.h" @@ -106,6 +107,9 @@ void pqExampleVisualizationsDialog::onButtonPressed() xmldata.replace("$PARAVIEW_EXAMPLES_DATA", dataPath); pqApplicationCore::instance()->loadStateFromString( xmldata.toUtf8().data(), pqActiveObjects::instance().activeServer()); + + // This is needed since XML state currently does not save active view. + pqLoadStateReaction::activateView(); } else { diff --git a/Qt/ApplicationComponents/pqLoadStateReaction.cxx b/Qt/ApplicationComponents/pqLoadStateReaction.cxx index 9345afb8510bce04f993da5850f05b2ad08fb644..7b03c240abbe2bba35c2854b754f784601a3ebd0 100644 --- a/Qt/ApplicationComponents/pqLoadStateReaction.cxx +++ b/Qt/ApplicationComponents/pqLoadStateReaction.cxx @@ -116,15 +116,9 @@ void pqLoadStateReaction::loadState(const QString& filename, bool dialogBlocked, server, filename); } pqPVApplicationCore::instance()->setLoadingState(false); - // activate a view in the state. - // this is needed since XML state currently does not save active view. - auto smmodel = pqApplicationCore::instance()->getServerManagerModel(); - auto views = smmodel->findItems(server); - if (views.size()) - { - pqActiveObjects::instance().setActiveView(views[0]); - } + // This is needed since XML state currently does not save active view. + pqLoadStateReaction::activateView(); } } else @@ -156,3 +150,15 @@ void pqLoadStateReaction::loadState() pqLoadStateReaction::loadState(selectedFile); } } + +//----------------------------------------------------------------------------- +void pqLoadStateReaction::activateView() +{ + auto server = pqActiveObjects::instance().activeServer(); + auto smmodel = pqApplicationCore::instance()->getServerManagerModel(); + auto views = smmodel->findItems(server); + if (views.size()) + { + pqActiveObjects::instance().setActiveView(views[0]); + } +} diff --git a/Qt/ApplicationComponents/pqLoadStateReaction.h b/Qt/ApplicationComponents/pqLoadStateReaction.h index 42ba454e48c8a1348dc98c76a73fd755ed45170a..0736ee24df547a83907cd50cc8f5080bbe8d1afd 100644 --- a/Qt/ApplicationComponents/pqLoadStateReaction.h +++ b/Qt/ApplicationComponents/pqLoadStateReaction.h @@ -62,6 +62,11 @@ public: const QString& filename, bool dialogBlocked = false, pqServer* server = NULL); static void loadState(); + /** + * Set default active view after state is loaded. Make the first view active. + */ + static void activateView(); + public slots: /** * Updates the enabled state. Applications need not explicitly call