Updates will be applied - 3:30pm EDT (UTC -400). No downtime expected.

Commit 7ec9faca authored by Ben Boeckel's avatar Ben Boeckel

Merge topic 'v1-multiload-just-say-no' into release

a70aeb99 Do not allow a model to be loaded multiple times.

Merge-request: !856
parents f44d20cf a70aeb99
......@@ -854,6 +854,33 @@ int LoadJSON::ofLocalSession(
if (!sref.isValid())
return status;
// Verify that none of the models are already present in the session.
// If they are, then fail rather than allow ambiguous state afterwards.
bool alreadyLoaded = false;
cJSON* jmodels = cJSON_GetObjectItem(node, "models");
if (jmodels)
{
for (cJSON* jmrec = jmodels->child; jmrec; jmrec = jmrec->next)
{
smtk::common::UUID muid;
if (jmrec && jmrec->string && !(muid = smtk::common::UUID(jmrec->string)).isNull())
{
if (context->findEntity(muid))
{
smtk::model::Model oops(context, muid);
smtkErrorMacro(context->log(), "Model \"" << oops.name() << "\" is already loaded.");
alreadyLoaded = true;
}
}
}
}
if (alreadyLoaded)
{
smtkErrorMacro(context->log(),
"Cannot load models when they are already loaded. Close data before reloading.");
return false;
}
// Ignore the XML definitions of the serialized session;
// recreating the session will recreate the attribute definitions.
(void)opsObj;
......
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