Commit 79e38efc authored by Cory Quammen's avatar Cory Quammen
Browse files

Delay view creation until plugins are loaded at initialization

This provides an opportunity to extended the default render view
via autoload plugin.
parent bb4f95eb
Pipeline #188369 running with stages
...@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqApplicationCore.h" #include "pqApplicationCore.h"
#include "pqCoreUtilities.h" #include "pqCoreUtilities.h"
#include "pqObjectBuilder.h" #include "pqObjectBuilder.h"
#include "pqPluginManager.h"
#include "pqRenderView.h" #include "pqRenderView.h"
#include "pqServer.h" #include "pqServer.h"
#include "pqServerManagerModel.h" #include "pqServerManagerModel.h"
...@@ -68,8 +69,19 @@ pqDefaultViewBehavior::pqDefaultViewBehavior(QObject* parentObject) ...@@ -68,8 +69,19 @@ pqDefaultViewBehavior::pqDefaultViewBehavior(QObject* parentObject)
QObject::connect(pqApplicationCore::instance()->getServerManagerModel(), QObject::connect(pqApplicationCore::instance()->getServerManagerModel(),
SIGNAL(serverAdded(pqServer*)), this, SLOT(onServerCreation(pqServer*))); SIGNAL(serverAdded(pqServer*)), this, SLOT(onServerCreation(pqServer*)));
this->ViewCreationTimer.setSingleShot(true);
this->ViewCreationTimer.setInterval(0);
this->connect(
&this->ViewCreationTimer, &pqTimer::timeout, [=] { this->createView(this->CurrentServer); });
this->WarningsTimer.setSingleShot(true); this->WarningsTimer.setSingleShot(true);
this->connect(&this->WarningsTimer, SIGNAL(timeout()), SLOT(showWarnings())); this->connect(&this->WarningsTimer, SIGNAL(timeout()), SLOT(showWarnings()));
// Listen for when plugins are loaded from settings. This marks the end
// of autoload plugins being loaded, and it being safe to create a view
// that may potentially be modified by a plugin.
this->connect(pqApplicationCore::instance()->getPluginManager(),
&pqPluginManager::initialPluginsLoaded, [=]() { this->AutoLoadPluginsFinishedLoading = true; });
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -128,8 +140,7 @@ void pqDefaultViewBehavior::showWarnings() ...@@ -128,8 +140,7 @@ void pqDefaultViewBehavior::showWarnings()
void pqDefaultViewBehavior::onServerCreation(pqServer* server) void pqDefaultViewBehavior::onServerCreation(pqServer* server)
{ {
using RCInfo = vtkPVRenderingCapabilitiesInformation; using RCInfo = vtkPVRenderingCapabilitiesInformation;
this->CurrentServer = server;
pqApplicationCore* core = pqApplicationCore::instance();
// Get information about rendering capabilities. // Get information about rendering capabilities.
vtkNew<RCInfo> info; vtkNew<RCInfo> info;
...@@ -147,8 +158,28 @@ void pqDefaultViewBehavior::onServerCreation(pqServer* server) ...@@ -147,8 +158,28 @@ void pqDefaultViewBehavior::onServerCreation(pqServer* server)
// Setup a timer to show warning messages, if needed. // Setup a timer to show warning messages, if needed.
this->WarningsTimer.start(500); this->WarningsTimer.start(500);
this->createView(this->CurrentServer);
// Show warning dialogs before server times out.
QObject::connect(
server, SIGNAL(fiveMinuteTimeoutWarning()), this, SLOT(fiveMinuteTimeoutWarning()));
QObject::connect(server, SIGNAL(finalTimeoutWarning()), this, SLOT(finalTimeoutWarning()));
}
//-----------------------------------------------------------------------------
void pqDefaultViewBehavior::createView(pqServer* server)
{
if (!this->AutoLoadPluginsFinishedLoading)
{
this->ViewCreationTimer.start();
return;
}
using RCInfo = vtkPVRenderingCapabilitiesInformation;
// See if some view are already present and if we're in a collaborative // See if some view are already present and if we're in a collaborative
// session, we are the master. // session, we are the master.
pqApplicationCore* core = pqApplicationCore::instance();
if (core->getServerManagerModel()->getNumberOfItems<pqView*>() == 0 && server->isMaster()) if (core->getServerManagerModel()->getNumberOfItems<pqView*>() == 0 && server->isMaster())
{ {
pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder(); pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
...@@ -164,11 +195,6 @@ void pqDefaultViewBehavior::onServerCreation(pqServer* server) ...@@ -164,11 +195,6 @@ void pqDefaultViewBehavior::onServerCreation(pqServer* server)
} }
} }
} }
// Show warning dialogs before server times out.
QObject::connect(
server, SIGNAL(fiveMinuteTimeoutWarning()), this, SLOT(fiveMinuteTimeoutWarning()));
QObject::connect(server, SIGNAL(finalTimeoutWarning()), this, SLOT(finalTimeoutWarning()));
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -57,6 +57,7 @@ public: ...@@ -57,6 +57,7 @@ public:
protected Q_SLOTS: protected Q_SLOTS:
void onServerCreation(pqServer*); void onServerCreation(pqServer*);
void createView(pqServer*);
void fiveMinuteTimeoutWarning(); void fiveMinuteTimeoutWarning();
void finalTimeoutWarning(); void finalTimeoutWarning();
...@@ -69,6 +70,9 @@ private: ...@@ -69,6 +70,9 @@ private:
vtkTypeUInt32 ClientCapabilities; vtkTypeUInt32 ClientCapabilities;
QPointer<pqServer> Server; QPointer<pqServer> Server;
pqTimer WarningsTimer; pqTimer WarningsTimer;
pqTimer ViewCreationTimer;
bool AutoLoadPluginsFinishedLoading = false;
pqServer* CurrentServer = nullptr;
}; };
#endif #endif
...@@ -166,6 +166,8 @@ void pqPluginManager::loadPluginsFromSettings() ...@@ -166,6 +166,8 @@ void pqPluginManager::loadPluginsFromSettings()
vtkSMProxyManager::GetProxyManager()->GetPluginManager()->LoadPluginConfigurationXMLFromString( vtkSMProxyManager::GetProxyManager()->GetPluginManager()->LoadPluginConfigurationXMLFromString(
local_plugin_config.toUtf8().data(), NULL, false); local_plugin_config.toUtf8().data(), NULL, false);
} }
Q_EMIT this->initialPluginsLoaded();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
......
...@@ -132,6 +132,11 @@ Q_SIGNALS: ...@@ -132,6 +132,11 @@ Q_SIGNALS:
*/ */
void requiredPluginsNotLoaded(pqServer*); void requiredPluginsNotLoaded(pqServer*);
/**
* Fired when the last set of autoload plugins are loaded during program initialization.
*/
void initialPluginsLoaded();
protected: protected:
void initialize(vtkSMPluginManager*); void initialize(vtkSMPluginManager*);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment