summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-10-05 08:20:21 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-10-06 12:17:07 +0300
commit6e08f4ec2f88f74005e2f4f276a5aa3c6917b3f4 (patch)
tree056603650e3c047dd38b5f64b56c35e31d07e797 /src
parentcabe218d8adbfca4bbd41c54c9aedd978239bf20 (diff)
SidebarWidget: Crash in TOC tab
The heading items will be obsolete if clicking in the sidebar before a page load finishes. IssueID #350
Diffstat (limited to 'src')
-rw-r--r--src/ui/sidebarwidget.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index fcdb5b9e..057ff614 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -876,10 +876,12 @@ static void itemClicked_SidebarWidget_(iSidebarWidget *d, iSidebarItem *item, si
876 switch (d->mode) { 876 switch (d->mode) {
877 case documentOutline_SidebarMode: { 877 case documentOutline_SidebarMode: {
878 const iGmDocument *doc = document_DocumentWidget(document_App()); 878 const iGmDocument *doc = document_DocumentWidget(document_App());
879 const iGmHeading *head = constAt_Array(headings_GmDocument(doc), item->id); 879 if (item->id < size_Array(headings_GmDocument(doc))) {
880 postCommandf_App("document.goto loc:%p", head->text.start); 880 const iGmHeading *head = constAt_Array(headings_GmDocument(doc), item->id);
881 dismissPortraitPhoneSidebars_Root(as_Widget(d)->root); 881 postCommandf_App("document.goto loc:%p", head->text.start);
882 setOpenedFromSidebar_DocumentWidget(document_App(), iTrue); 882 dismissPortraitPhoneSidebars_Root(as_Widget(d)->root);
883 setOpenedFromSidebar_DocumentWidget(document_App(), iTrue);
884 }
883 break; 885 break;
884 } 886 }
885 case feeds_SidebarMode: { 887 case feeds_SidebarMode: {