| 215 | } |
| 216 | |
| 217 | Result CtrlrPanel::restoreState (const ValueTree &savedState) |
| 218 | { |
| 219 | _DBG("CtrlrPanel::restoreState"); |
| 220 | |
| 221 | setRestoreState (true); |
| 222 | |
| 223 | panelTree.removeProperty (Ids::panelScheme, nullptr); |
| 224 | |
| 225 | // We need panel file property to be able to restore relative paths on lua methods |
| 226 | var filePath = savedState.getProperty(Ids::panelFilePath); |
| 227 | if (filePath.isVoid()) |
| 228 | { // File path not provided (new Panel) => get a default one |
| 229 | File userDocsDir = File::getSpecialLocation(File::SpecialLocationType::userDocumentsDirectory); |
| 230 | File panelFile = userDocsDir.getNonexistentChildFile("CtrlrPanel", ".panel"); |
| 231 | filePath = panelFile.getFullPathName(); |
| 232 | } |
| 233 | panelTree.setProperty(Ids::panelFilePath, filePath, nullptr); |
| 234 | |
| 235 | ctrlrLuaManager->restoreState(savedState.getChildWithName(Ids::luaManager)); |
| 236 | |
| 237 | if ((int)savedState.getProperty(Ids::panelScheme) < CTRLR_PANEL_SCHEME) |
| 238 | upgradeScheme(); |
| 239 | |
| 240 | for (int i=0; i<savedState.getNumProperties(); i++) |
| 241 | { |
| 242 | panelTree.setProperty (savedState.getPropertyName(i), savedState.getProperty(savedState.getPropertyName(i), 0), 0); |
| 243 | } |
| 244 | |
| 245 | if (savedState.getChildWithName(Ids::resourceExportList).isValid()) |
| 246 | { |
| 247 | Result resourceImport = resourceManager.restoreState(savedState.getChildWithName(Ids::resourceExportList)); |
| 248 | |
| 249 | if (!resourceImport.wasOk()) |
| 250 | { |
| 251 | WARN("Failed to load panel: " + resourceImport.getErrorMessage()); |
| 252 | |
| 253 | setRestoreState (false); |
| 254 | return (resourceImport); |
| 255 | } |
| 256 | } |
| 257 | else if (owner.getInstanceResourcesTree().isValid()) |
| 258 | { |
| 259 | Result resourceImport = getResourceManager().restoreState(owner.getInstanceResourcesTree()); |
| 260 | |
| 261 | if (!resourceImport.wasOk()) |
| 262 | { |
| 263 | WARN("Failed to load panel: " + resourceImport.getErrorMessage()); |
| 264 | |
| 265 | setRestoreState (false); |
| 266 | return (resourceImport); |
| 267 | } |
| 268 | } |
| 269 | else |
| 270 | { // Try and load missing resources from source files |
| 271 | ValueTree panelResourcesTree = savedState.getChildWithName(Ids::panelResources); |
| 272 | if(panelResourcesTree.isValid()) |
| 273 | { |
| 274 | getResourceManager().checkMissingResources(panelResourcesTree); |
nothing calls this directly
no test coverage detected