MCPcopy Create free account
hub / github.com/MrKepzie/Natron / restoreFromSerialization

Method restoreFromSerialization

Engine/ProjectPrivate.cpp:99–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99bool
100ProjectPrivate::restoreFromSerialization(const ProjectSerialization & obj,
101 const QString& name,
102 const QString& path,
103 bool* mustSave)
104{
105 /*1st OFF RESTORE THE PROJECT KNOBS*/
106 bool ok;
107 {
108 CreatingNodeTreeFlag_RAII creatingNodeTreeFlag( _publicInterface->getApp() );
109
110 projectCreationTime = QDateTime::fromMSecsSinceEpoch( obj.getCreationDate() );
111
112 _publicInterface->getApp()->updateProjectLoadStatus( tr("Restoring project settings...") );
113
114 /*we must restore the entries in the combobox before restoring the value*/
115 std::vector<ChoiceOption> entries;
116
117 for (std::list<Format>::const_iterator it = builtinFormats.begin(); it != builtinFormats.end(); ++it) {
118 QString formatStr = ProjectPrivate::generateStringFromFormat(*it);
119 if ( !it->getName().empty() ) {
120 entries.push_back( ChoiceOption(it->getName(), formatStr.toStdString(), "") );
121 } else {
122 entries.push_back( ChoiceOption( formatStr.toStdString() ) );
123 }
124 }
125
126 const std::list<Format> & objAdditionalFormats = obj.getAdditionalFormats();
127 for (std::list<Format>::const_iterator it = objAdditionalFormats.begin(); it != objAdditionalFormats.end(); ++it) {
128 QString formatStr = ProjectPrivate::generateStringFromFormat(*it);
129 if ( !it->getName().empty() ) {
130 entries.push_back( ChoiceOption(it->getName(), formatStr.toStdString(), "") );
131 } else {
132 entries.push_back( ChoiceOption( formatStr.toStdString() ) );
133 }
134 }
135 additionalFormats = objAdditionalFormats;
136
137 formatKnob->populateChoices(entries);
138 autoSetProjectFormat = false;
139
140 const std::list< boost::shared_ptr<KnobSerialization> > & projectSerializedValues = obj.getProjectKnobsValues();
141 const std::vector< KnobPtr > & projectKnobs = _publicInterface->getKnobs();
142
143 /// 1) restore project's knobs.
144 for (U32 i = 0; i < projectKnobs.size(); ++i) {
145 ///try to find a serialized value for this knob
146 for (std::list< boost::shared_ptr<KnobSerialization> >::const_iterator it = projectSerializedValues.begin(); it != projectSerializedValues.end(); ++it) {
147 if ( (*it)->getName() == projectKnobs[i]->getName() ) {
148 ///EDIT: Allow non persistent params to be loaded if we found a valid serialization for them
149 //if ( projectKnobs[i]->getIsPersistent() ) {
150
151 KnobChoice* isChoice = dynamic_cast<KnobChoice*>( projectKnobs[i].get() );
152 if (isChoice) {
153 const TypeExtraData* extraData = (*it)->getExtraData();
154 const ChoiceExtraData* choiceData = dynamic_cast<const ChoiceExtraData*>(extraData);
155 assert(choiceData);
156 if (choiceData) {

Callers 1

loadMethod · 0.45

Calls 15

generateStringFromFormatFunction · 0.85
ChoiceOptionFunction · 0.85
emptyMethod · 0.80
getNameMethod · 0.80
toStdStringMethod · 0.80
getAdditionalFormatsMethod · 0.80
populateChoicesMethod · 0.80
getExtraDataMethod · 0.80
choiceRestorationIdMethod · 0.80
choiceRestorationMethod · 0.80
getAppTypeMethod · 0.80

Tested by

no test coverage detected