Commit 6e5d0fb1 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 #188368 waiting for manual action with stages
......@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqApplicationCore.h"
#include "pqCoreUtilities.h"
#include "pqObjectBuilder.h"
#include "pqPluginManager.h"
#include "pqRenderView.h"
#include "pqServer.h"
#include "pqServerManagerModel.h"
......@@ -68,8 +69,23 @@ pqDefaultViewBehavior::pqDefaultViewBehavior(QObject* parentObject)
QObject::connect(pqApplicationCore::instance()->getServerManagerModel(),
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->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 +144,7 @@ void pqDefaultViewBehavior::showWarnings()
void pqDefaultViewBehavior::onServerCreation(pqServer* server)
{
using RCInfo = vtkPVRenderingCapabilitiesInformation;
pqApplicationCore* core = pqApplicationCore::instance();
this->CurrentServer = server;
// Get information about rendering capabilities.
vtkNew<RCInfo> info;
......@@ -147,8 +162,28 @@ void pqDefaultViewBehavior::onServerCreation(pqServer* server)
// Setup a timer to show warning messages, if needed.
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
// session, we are the master.
pqApplicationCore* core = pqApplicationCore::instance();
if (core->getServerManagerModel()->getNumberOfItems<pqView*>() == 0 && server->isMaster())
{
pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder();
......@@ -164,11 +199,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:
protected Q_SLOTS:
void onServerCreation(pqServer*);
void createView(pqServer*);
void fiveMinuteTimeoutWarning();
void finalTimeoutWarning();
......@@ -69,6 +70,9 @@ private:
vtkTypeUInt32 ClientCapabilities;
QPointer<pqServer> Server;
pqTimer WarningsTimer;
pqTimer ViewCreationTimer;
bool AutoLoadPluginsFinishedLoading = false;
pqServer* CurrentServer = nullptr;
};
#endif
......@@ -166,6 +166,8 @@ void pqPluginManager::loadPluginsFromSettings()
vtkSMProxyManager::GetProxyManager()->GetPluginManager()->LoadPluginConfigurationXMLFromString(
local_plugin_config.toUtf8().data(), NULL, false);
}
Q_EMIT this->initialPluginsLoaded();
}
//-----------------------------------------------------------------------------
......
......@@ -132,6 +132,11 @@ Q_SIGNALS:
*/
void requiredPluginsNotLoaded(pqServer*);
/**
* Fired when the last set of autoload plugins are loaded during program initialization.
*/
void initialPluginsLoaded();
protected:
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