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

Method restoreFromSerialization

Engine/ProjectPrivate.cpp:106–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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