Index: src/story_gui.cpp =================================================================== --- src/story_gui.cpp (revision 27382) +++ src/story_gui.cpp (working copy) @@ -684,13 +684,16 @@ */ virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { - if (!gui_scope) return; - /* If added/removed page, force rebuild. Sort order never change so just a * re-sort is never needed. */ if (data == -1) { + /* Pointer in story_pages may have become invalid. Clear them immediately */ this->story_pages.ForceRebuild(); + this->story_pages.Clear(); + + if (!gui_scope) return; + this->BuildStoryPageList(); /* Was the last page removed? */ @@ -713,6 +716,12 @@ this->SetWidgetDirty(WID_SB_SEL_PAGE); this->UpdatePrevNextDisabledState(); } else if (data >= 0 && this->selected_page_id == data) { + /* Pointer in story_page_elements may have become invalid. Clear them immediately */ + this->story_page_elements.ForceRebuild(); + this->story_page_elements.Clear(); + + if (!gui_scope) return; + this->RefreshSelectedPage(); } }