diff options
author | Charles Pigott <charlespigott@googlemail.com> | 2020-06-27 14:14:21 +0100 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2020-06-27 16:07:08 +0100 |
commit | 4c45448fa9d9bc7dabe7e971bf4b56ba7e595693 (patch) | |
tree | 323d97214fd19133e339e84fc961e5849d7af695 /src | |
parent | dc8d0089e95a0fb9a77330fe890f72ac3bb430ea (diff) | |
download | openttd-4c45448fa9d9bc7dabe7e971bf4b56ba7e595693.tar.xz |
Fix #8129: Crash if a news message expires while viewing the endgame screen
Diffstat (limited to 'src')
-rw-r--r-- | src/news_gui.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 9993645c4..0b4c41a2a 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -671,6 +671,11 @@ static bool ReadyForNextNewsItem() /** Move to the next ticker item */ static void MoveToNextTickerItem() { + /* There is no status bar, so no reason to show news; + * especially important with the end game screen when + * there is no status bar but possible news. */ + if (FindWindowById(WC_STATUS_BAR, 0) == nullptr) return; + InvalidateWindowData(WC_STATUS_BAR, 0, SBI_NEWS_DELETED); // invalidate the statusbar /* if we're not at the last item, then move on */ @@ -702,6 +707,11 @@ static void MoveToNextTickerItem() /** Move to the next news item */ static void MoveToNextNewsItem() { + /* There is no status bar, so no reason to show news; + * especially important with the end game screen when + * there is no status bar but possible news. */ + if (FindWindowById(WC_STATUS_BAR, 0) == nullptr) return; + DeleteWindowById(WC_NEWS_WINDOW, 0); // close the newspapers window if shown _forced_news = nullptr; @@ -995,11 +1005,6 @@ void NewsLoop() /* no news item yet */ if (_total_news == 0) return; - /* There is no status bar, so no reason to show news; - * especially important with the end game screen when - * there is no status bar but possible news. */ - if (FindWindowById(WC_STATUS_BAR, 0) == nullptr) return; - static byte _last_clean_month = 0; if (_last_clean_month != _cur_month) { |