Fix 2884 crash on page delete

This commit is contained in:
WandererFan 2017-02-01 19:05:49 -05:00
parent 86363caa56
commit 2c7afffd9a

View File

@ -335,10 +335,12 @@ void DrawPage::unsetupObject()
}
Views.setValues(emptyViews);
//no template crash here?? if Template.getValue is null or invalid, this will fail.
std::string templateName = Template.getValue()->getNameInDocument();
Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
docName.c_str(), templateName.c_str());
App::DocumentObject* tmp = Template.getValue();
if (tmp != nullptr) {
std::string templateName = Template.getValue()->getNameInDocument();
Base::Interpreter().runStringArg("App.getDocument(\"%s\").removeObject(\"%s\")",
docName.c_str(), templateName.c_str());
}
Template.setValue(nullptr);
}