fix UB in story_viewer
previously the first image timer would not be cleared when the user restarted the part, which in particular caused UB if the story_viewer was closed before all timers have finished. fixes #3838 fixes #3837
This commit is contained in:
parent
7baad6ea41
commit
cad013c4de
2 changed files with 10 additions and 2 deletions
|
@ -67,7 +67,7 @@ story_viewer::story_viewer(const std::string& scenario_name, const config& cfg_p
|
|||
update_current_part_ptr();
|
||||
}
|
||||
|
||||
story_viewer::~story_viewer()
|
||||
void story_viewer::clear_image_timer()
|
||||
{
|
||||
if(timer_id_ != 0) {
|
||||
remove_timer(timer_id_);
|
||||
|
@ -75,6 +75,11 @@ story_viewer::~story_viewer()
|
|||
}
|
||||
}
|
||||
|
||||
story_viewer::~story_viewer()
|
||||
{
|
||||
clear_image_timer();
|
||||
}
|
||||
|
||||
void story_viewer::pre_show(window& window)
|
||||
{
|
||||
window.set_enter_disabled(true);
|
||||
|
@ -294,7 +299,8 @@ void story_viewer::display_part(window& window)
|
|||
text_label.set_label(part_text);
|
||||
|
||||
begin_fade_draw(true);
|
||||
|
||||
// if the previous page was skipped, it is possible that we already have a timer running.
|
||||
clear_image_timer();
|
||||
//
|
||||
// Floating images (handle this last)
|
||||
//
|
||||
|
|
|
@ -50,6 +50,8 @@ private:
|
|||
/** Inherited from modal_dialog. */
|
||||
virtual void pre_show(window& window) override;
|
||||
|
||||
void clear_image_timer();
|
||||
|
||||
void update_current_part_ptr();
|
||||
|
||||
void display_part(window& window);
|
||||
|
|
Loading…
Add table
Reference in a new issue