mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 06:00:48 +00:00
Skip initial view controller if it doesn't exist
This commit is contained in:
parent
43feefce68
commit
7850f8e61b
2 changed files with 77 additions and 58 deletions
|
@ -612,68 +612,82 @@
|
||||||
if ([docNodes count] > 0)
|
if ([docNodes count] > 0)
|
||||||
{
|
{
|
||||||
NSXMLElement *docNode = [docNodes objectAtIndex: 0];
|
NSXMLElement *docNode = [docNodes objectAtIndex: 0];
|
||||||
NSArray *array = [docNode nodesForXPath: @"//scene" error: NULL];
|
|
||||||
NSArray *firstResponderIdNodes = [docNode nodesForXPath: @"//objects/customObject[@sceneMemberID =\"firstResponder\"]/@id"
|
|
||||||
error: NULL];
|
|
||||||
NSString *firstResponderId = @"-1";
|
|
||||||
|
|
||||||
if([firstResponderIdNodes count] > 0)
|
if (docNode != nil)
|
||||||
{
|
{
|
||||||
firstResponderId = [[firstResponderIdNodes objectAtIndex: 0] stringValue];
|
NSArray *array = [docNode nodesForXPath: @"//scene" error: NULL];
|
||||||
}
|
NSArray *firstResponderIdNodes = [docNode nodesForXPath: @"//objects/customObject[@sceneMemberID =\"firstResponder\"]/@id"
|
||||||
|
error: NULL];
|
||||||
// Set initial view controller...
|
NSString *firstResponderId = @"-1";
|
||||||
ASSIGN(_initialViewControllerId, [[docNode attributeForName: @"initialViewController"] stringValue]);
|
NSXMLNode *initialViewControllerNode = [docNode attributeForName: @"initialViewController"];
|
||||||
FOR_IN(NSXMLElement*, e, array)
|
|
||||||
{
|
if([firstResponderIdNodes count] > 0)
|
||||||
NSXMLElement *doc = [[NSXMLElement alloc] initWithName: @"document"];
|
{
|
||||||
NSArray *children = [e children];
|
firstResponderId = [[firstResponderIdNodes objectAtIndex: 0] stringValue];
|
||||||
NSXMLDocument *document = nil;
|
}
|
||||||
NSString *sceneId = [[e attributeForName: @"sceneID"] stringValue];
|
|
||||||
NSString *controllerId = nil;
|
|
||||||
// Move children...
|
|
||||||
FOR_IN(NSXMLElement*, child, children)
|
|
||||||
{
|
|
||||||
if ([[child name] isEqualToString: @"point"] == YES)
|
|
||||||
continue; // go on if it's a point element, we don't use that in the app...
|
|
||||||
|
|
||||||
NSArray *subnodes = [child nodesForXPath: @"//application" error: NULL];
|
|
||||||
NSXMLNode *appNode = [subnodes objectAtIndex: 0];
|
|
||||||
[self processChild: child
|
|
||||||
withDoc: doc
|
|
||||||
withAppNode: appNode
|
|
||||||
sceneId: sceneId
|
|
||||||
firstResponderId: firstResponderId];
|
|
||||||
|
|
||||||
// fix other custom objects
|
|
||||||
document = [[NSXMLDocument alloc] initWithRootElement: doc];
|
|
||||||
controllerId = [self controllerIdWithDocument: document];
|
|
||||||
controllerId = (controllerId != nil) ? controllerId : APPLICATION;
|
|
||||||
RELEASE(doc);
|
|
||||||
|
|
||||||
// Create document...
|
|
||||||
[_scenesMap setObject: document
|
|
||||||
forKey: sceneId];
|
|
||||||
|
|
||||||
// Map controllerId's to scenes...
|
|
||||||
if (controllerId != nil)
|
|
||||||
{
|
|
||||||
[_controllerMap setObject: sceneId
|
|
||||||
forKey: controllerId];
|
|
||||||
|
|
||||||
[self processSegues: document
|
// Set initial view controller...
|
||||||
forControllerId: controllerId];
|
if (initialViewControllerNode != nil)
|
||||||
}
|
{
|
||||||
RELEASE(document);
|
ASSIGN(_initialViewControllerId, [[docNode attributeForName: @"initialViewController"] stringValue]);
|
||||||
}
|
}
|
||||||
END_FOR_IN(children);
|
|
||||||
}
|
FOR_IN(NSXMLElement*, e, array)
|
||||||
END_FOR_IN(array);
|
{
|
||||||
|
NSXMLElement *doc = [[NSXMLElement alloc] initWithName: @"document"];
|
||||||
|
NSArray *children = [e children];
|
||||||
|
NSXMLDocument *document = nil;
|
||||||
|
NSString *sceneId = [[e attributeForName: @"sceneID"] stringValue];
|
||||||
|
NSString *controllerId = nil;
|
||||||
|
// Move children...
|
||||||
|
FOR_IN(NSXMLElement*, child, children)
|
||||||
|
{
|
||||||
|
if ([[child name] isEqualToString: @"point"] == YES)
|
||||||
|
continue; // go on if it's a point element, we don't use that in the app...
|
||||||
|
|
||||||
|
NSArray *subnodes = [child nodesForXPath: @"//application" error: NULL];
|
||||||
|
NSXMLNode *appNode = [subnodes objectAtIndex: 0];
|
||||||
|
[self processChild: child
|
||||||
|
withDoc: doc
|
||||||
|
withAppNode: appNode
|
||||||
|
sceneId: sceneId
|
||||||
|
firstResponderId: firstResponderId];
|
||||||
|
|
||||||
|
// fix other custom objects
|
||||||
|
document = [[NSXMLDocument alloc] initWithRootElement: doc];
|
||||||
|
controllerId = [self controllerIdWithDocument: document];
|
||||||
|
controllerId = (controllerId != nil) ? controllerId : APPLICATION;
|
||||||
|
RELEASE(doc);
|
||||||
|
|
||||||
|
// Create document...
|
||||||
|
[_scenesMap setObject: document
|
||||||
|
forKey: sceneId];
|
||||||
|
|
||||||
|
// Map controllerId's to scenes...
|
||||||
|
if (controllerId != nil)
|
||||||
|
{
|
||||||
|
[_controllerMap setObject: sceneId
|
||||||
|
forKey: controllerId];
|
||||||
|
|
||||||
|
[self processSegues: document
|
||||||
|
forControllerId: controllerId];
|
||||||
|
}
|
||||||
|
RELEASE(document);
|
||||||
|
}
|
||||||
|
END_FOR_IN(children);
|
||||||
|
}
|
||||||
|
END_FOR_IN(array);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[NSException raise: NSInternalInconsistencyException
|
||||||
|
format: @"No document element found in storyboard file"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[NSException raise: NSInternalInconsistencyException
|
[NSException raise: NSInternalInconsistencyException
|
||||||
format: @"No document element found in storyboard file"];
|
format: @"Document node returned nil"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,8 +164,13 @@ static NSStoryboard *__mainStoryboard = nil;
|
||||||
|
|
||||||
- (id) instantiateControllerWithIdentifier: (NSStoryboardSceneIdentifier)identifier
|
- (id) instantiateControllerWithIdentifier: (NSStoryboardSceneIdentifier)identifier
|
||||||
{
|
{
|
||||||
return [self instantiateControllerWithIdentifier: identifier
|
if (identifier != nil)
|
||||||
creator: nil];
|
{
|
||||||
|
return [self instantiateControllerWithIdentifier: identifier
|
||||||
|
creator: nil];
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) instantiateControllerWithIdentifier: (NSStoryboardSceneIdentifier)identifier
|
- (id) instantiateControllerWithIdentifier: (NSStoryboardSceneIdentifier)identifier
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue