+ fixes issue #0002224: Drawings break on reopen. Template not found

This commit is contained in:
wmayer 2016-05-05 11:11:08 +02:00
parent 1e061b5c02
commit cc88b376e1
3 changed files with 47 additions and 32 deletions

View File

@ -56,9 +56,9 @@ FeaturePage::FeaturePage(void) : numChildren(0)
{
static const char *group = "Drawing view";
ADD_PROPERTY_TYPE(PageResult ,(0),group,App::Prop_Output,"Resulting SVG document of that page");
ADD_PROPERTY_TYPE(Template ,(""),group,App::Prop_Transient ,"Template for the page");
ADD_PROPERTY_TYPE(EditableTexts,(""),group,App::Prop_None,"Substitution values for the editable strings in the template");
ADD_PROPERTY_TYPE(PageResult, (0), group, App::Prop_Output, "Resulting SVG document of that page");
ADD_PROPERTY_TYPE(Template, (""), group, App::Prop_None, "Template for the page");
ADD_PROPERTY_TYPE(EditableTexts, (""), group, App::Prop_None, "Substitution values for the editable strings in the template");
}
FeaturePage::~FeaturePage()
@ -107,17 +107,22 @@ void FeaturePage::onChanged(const App::Property* prop)
void FeaturePage::onDocumentRestored()
{
// Needs to be tmp. set because otherwise the custom text gets overridden (#0002064)
this->StatusBits.set(4); // the 'Restore' flag
this->StatusBits.set(App::Restore); // the 'Restore' flag
Base::FileInfo fi(PageResult.getValue());
std::string path = App::Application::getResourceDir() + "Mod/Drawing/Templates/" + fi.fileName();
// try to find the template in user dir/Templates first
Base::FileInfo tempfi(App::Application::getUserAppDataDir() + "Templates/" + fi.fileName());
if (tempfi.exists())
path = tempfi.filePath();
Template.setValue(path);
Base::FileInfo templateInfo(Template.getValue());
if (!templateInfo.exists()) {
Base::FileInfo fi(Template.getValue());
if (fi.fileName().empty())
fi.setFile(PageResult.getValue());
std::string path = App::Application::getResourceDir() + "Mod/Drawing/Templates/" + fi.fileName();
// try to find the template in user dir/Templates first
Base::FileInfo tempfi(App::Application::getUserAppDataDir() + "Templates/" + fi.fileName());
if (tempfi.exists())
path = tempfi.filePath();
Template.setValue(path);
}
this->StatusBits.reset(4); // the 'Restore' flag
this->StatusBits.reset(App::Restore); // the 'Restore' flag
}
App::DocumentObjectExecReturn *FeaturePage::execute(void)

View File

@ -46,20 +46,25 @@ PROPERTY_SOURCE(Raytracing::LuxProject, App::DocumentObjectGroup)
LuxProject::LuxProject(void)
{
ADD_PROPERTY_TYPE(PageResult ,(0),0,App::Prop_Output,"Resulting Luxrender Scene file");
ADD_PROPERTY_TYPE(Template ,(""),0,App::Prop_Transient ,"Template for the Luxrender project");
ADD_PROPERTY_TYPE(Camera ,(""),0,App::Prop_None ,"Camera settings");
ADD_PROPERTY_TYPE(PageResult, (0), 0, App::Prop_Output, "Resulting Luxrender Scene file");
ADD_PROPERTY_TYPE(Template, (""), 0, App::Prop_None, "Template for the Luxrender project");
ADD_PROPERTY_TYPE(Camera, (""), 0, App::Prop_None, "Camera settings");
}
void LuxProject::onDocumentRestored()
{
Base::FileInfo fi(PageResult.getValue());
std::string path = App::Application::getResourceDir() + "Mod/Raytracing/Templates/" + fi.fileName();
// try to find the template in user dir/Templates first
Base::FileInfo tempfi(App::Application::getUserAppDataDir() + "Templates/" + fi.fileName());
if (tempfi.exists())
path = tempfi.filePath();
Template.setValue(path);
Base::FileInfo templateInfo(Template.getValue());
if (!templateInfo.exists()) {
Base::FileInfo fi(Template.getValue());
if (fi.fileName().empty())
fi.setFile(PageResult.getValue());
std::string path = App::Application::getResourceDir() + "Mod/Raytracing/Templates/" + fi.fileName();
// try to find the template in user dir/Templates first
Base::FileInfo tempfi(App::Application::getUserAppDataDir() + "Templates/" + fi.fileName());
if (tempfi.exists())
path = tempfi.filePath();
Template.setValue(path);
}
}
App::DocumentObjectExecReturn *LuxProject::execute(void)

View File

@ -45,20 +45,25 @@ PROPERTY_SOURCE(Raytracing::RayProject, App::DocumentObjectGroup)
RayProject::RayProject(void)
{
ADD_PROPERTY_TYPE(PageResult ,(0),0,App::Prop_Output,"Resulting povray Project file");
ADD_PROPERTY_TYPE(Template ,(""),0,App::Prop_Transient ,"Template for the Povray project");
ADD_PROPERTY_TYPE(Camera ,(""),0,App::Prop_None ,"Camera settings");
ADD_PROPERTY_TYPE(PageResult, (0), 0, App::Prop_Output, "Resulting povray Project file");
ADD_PROPERTY_TYPE(Template, (""), 0, App::Prop_None, "Template for the Povray project");
ADD_PROPERTY_TYPE(Camera, (""), 0, App::Prop_None, "Camera settings");
}
void RayProject::onDocumentRestored()
{
Base::FileInfo fi(PageResult.getValue());
std::string path = App::Application::getResourceDir() + "Mod/Raytracing/Templates/" + fi.fileName();
// try to find the template in user dir/Templates first
Base::FileInfo tempfi(App::Application::getUserAppDataDir() + "Templates/" + fi.fileName());
if (tempfi.exists())
path = tempfi.filePath();
Template.setValue(path);
Base::FileInfo templateInfo(Template.getValue());
if (!templateInfo.exists()) {
Base::FileInfo fi(Template.getValue());
if (fi.fileName().empty())
fi.setFile(PageResult.getValue());
std::string path = App::Application::getResourceDir() + "Mod/Raytracing/Templates/" + fi.fileName();
// try to find the template in user dir/Templates first
Base::FileInfo tempfi(App::Application::getUserAppDataDir() + "Templates/" + fi.fileName());
if (tempfi.exists())
path = tempfi.filePath();
Template.setValue(path);
}
}
App::DocumentObjectExecReturn *RayProject::execute(void)