Do not restore project state for projects with no documents

The state being restored here would be file browser state, which might confuse the user if they are opening a folder via “mate” and then get a file browser restored for that project folder that show another location than the actual folder they open.

The reason we ignore the state when loading, rather than not saving it in the first place, is that by saving the state we make the folder show up in File → Open Favorites…
This commit is contained in:
Allan Odgaard
2014-03-24 23:36:17 +07:00
parent 69504292e5
commit 73453e5152

View File

@@ -2668,8 +2668,11 @@ static NSUInteger DisableSessionSavingCount = 0;
else if(controller.selectedDocument)
[controller selectedDocument]->set_custom_name("not untitled"); // release potential untitled token used
BOOL disableFolderStateRestore = [[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsDisableFolderStateRestore];
if(NSDictionary* project = (disableFolderStateRestore ? nil : [[DocumentController sharedProjectStateDB] valueForKey:[NSString stringWithCxxString:folder]]))
NSDictionary* project;
if(![[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsDisableFolderStateRestore])
project = [[DocumentController sharedProjectStateDB] valueForKey:[NSString stringWithCxxString:folder]];
if(project && [project[@"documents"] count])
{
[controller setupControllerForProject:project skipMissingFiles:YES];
}