| 104 | } |
| 105 | |
| 106 | bool |
| 107 | ProjectPrivate::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); |
no test coverage detected