diff options
author | fredrossperry <fredrossperry@gmail.com> | 2016-04-19 16:59:57 -0700 |
---|---|---|
committer | fredrossperry <fredrossperry@gmail.com> | 2016-04-20 11:27:40 -0700 |
commit | 441fd0d2d813d0453c942566bdb43393662bb261 (patch) | |
tree | e8b6cbfdc2129142ef31b81dc0fd0a64ebcdef50 /platform | |
parent | 8dd742e03881026d9474d67661964a2e95badada (diff) | |
download | mupdf-441fd0d2d813d0453c942566bdb43393662bb261.tar.xz |
Fix bug 696718 by deferring creation of the outline until it's about to be shown.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/ios/Classes/MuDocumentController.m | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m index 03abf2aa..7c3f292c 100644 --- a/platform/ios/Classes/MuDocumentController.m +++ b/platform/ios/Classes/MuDocumentController.m @@ -173,19 +173,10 @@ static void saveDoc(char *current_path, fz_document *doc) doc = docRef->doc; filePath = strdup(cstr); - dispatch_sync(queue, ^{}); + // this will be created right before the outline is shown + outline = nil; - fz_outline *root = fz_load_outline(ctx, doc); - if (root) { - NSMutableArray *titles = [[NSMutableArray alloc] init]; - NSMutableArray *pages = [[NSMutableArray alloc] init]; - flattenOutline(titles, pages, root, 0); - if ([titles count]) - outline = [[MuOutlineController alloc] initWithTarget: self titles: titles pages: pages]; - [titles release]; - [pages release]; - fz_drop_outline(ctx, root); - } + dispatch_sync(queue, ^{}); return self; } @@ -284,9 +275,14 @@ static void saveDoc(char *current_path, fz_document *doc) // Set up the buttons on the navigation and search bar - if (outline) { + fz_outline *outlineRoot = fz_load_outline(ctx, doc); + if (outlineRoot) + { + // only show the outline button if there is an outline outlineButton = [self newResourceBasedButton:@"ic_list" withAction:@selector(onShowOutline:)]; + fz_drop_outline(ctx, outlineRoot); } + linkButton = [self newResourceBasedButton:@"ic_link" withAction:@selector(onToggleLinks:)]; cancelButton = [self newResourceBasedButton:@"ic_cancel" withAction:@selector(onCancel:)]; searchButton = [self newResourceBasedButton:@"ic_magnifying_glass" withAction:@selector(onShowSearch:)]; @@ -477,6 +473,26 @@ static void saveDoc(char *current_path, fz_document *doc) - (void) onShowOutline: (id)sender { + // rebuild the outline in case the layout has changed + + if (!outline) + [outline release]; + + fz_outline *root = fz_load_outline(ctx, doc); + if (root) + { + NSMutableArray *titles = [[NSMutableArray alloc] init]; + NSMutableArray *pages = [[NSMutableArray alloc] init]; + flattenOutline(titles, pages, root, 0); + if ([titles count]) + outline = [[MuOutlineController alloc] initWithTarget: self titles: titles pages: pages]; + [titles release]; + [pages release]; + fz_drop_outline(ctx, root); + } + + // now show it + [[self navigationController] pushViewController: outline animated: YES]; } |