Commit a70aeb99 authored by David Thompson's avatar David Thompson

Do not allow a model to be loaded multiple times.

parent 18e83770
......@@ -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 \"" << << "\" is already loaded.");
alreadyLoaded = true;
if (alreadyLoaded)
"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.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment