diff options
author | frosch <frosch@openttd.org> | 2013-03-17 14:41:09 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-03-17 14:41:09 +0000 |
commit | b09743f3e88ea87e0767390a1e6aeb481a7e59e7 (patch) | |
tree | 95634a5e57496dd0e73f52d14f42ebc039530de5 /src | |
parent | c2c50b0c507d427caa32f71eda009bba95fac684 (diff) | |
download | openttd-b09743f3e88ea87e0767390a1e6aeb481a7e59e7.tar.xz |
(svn r25093) -Fix [FS#5486]: Clicking the statusbar crashed, when news were pending but no news were shown yet. (3298)
Diffstat (limited to 'src')
-rw-r--r-- | src/news_gui.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/news_gui.cpp b/src/news_gui.cpp index cb2c79f49..a0c9bdbd2 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -909,8 +909,14 @@ void ShowLastNewsMessage() } else if (_forced_news == NULL) { /* Not forced any news yet, show the current one, unless a news window is * open (which can only be the current one), then show the previous item */ - const Window *w = FindWindowById(WC_NEWS_WINDOW, 0); - ni = (w == NULL || (_current_news == _oldest_news)) ? _current_news : _current_news->prev; + if (_current_news == NULL) { + /* No news were shown yet resp. the last shown one was already deleted. + * Threat this as if _forced_news reached _oldest_news; so, wrap around and start anew with the latest. */ + ni = _latest_news; + } else { + const Window *w = FindWindowById(WC_NEWS_WINDOW, 0); + ni = (w == NULL || (_current_news == _oldest_news)) ? _current_news : _current_news->prev; + } } else if (_forced_news == _oldest_news) { /* We have reached the oldest news, start anew with the latest */ ni = _latest_news; |