widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #04498
[Merge] lp:~widelands-dev/widelands/bug-1509301 into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1509301 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1509301 in widelands: "Loading older multiplayer savegame doesn't work"
https://bugs.launchpad.net/widelands/+bug/1509301
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1509301/+merge/275624
Fixed the crash.
What happens here is that the old savegame causes an exception to be thrown. Because of the exception, the ChatOverlay never got assigned a specific ChatProvider, only the generic one. The generic one contains only virtual methods. So, I added a check for this.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1509301 into lp:widelands.
=== modified file 'src/wui/chatoverlay.cc'
--- src/wui/chatoverlay.cc 2015-10-04 19:53:09 +0000
+++ src/wui/chatoverlay.cc 2015-10-24 12:20:35 +0000
@@ -21,6 +21,7 @@
#include <memory>
+#include "base/macros.h"
#include "chat/chat.h"
#include "graphic/font_handler1.h"
#include "graphic/rendertarget.h"
@@ -67,6 +68,15 @@
}
void recompute();
+
+private:
+ bool has_chat_provider() {
+ if (chat_ == nullptr) return false;
+ // The chat provider might not have been assigned a specific subclass,
+ // e.g. if there was an exception thrown.
+ if (is_a(ChatProvider, chat_)) return false;
+ return true;
+ }
};
ChatOverlay::ChatOverlay
@@ -116,7 +126,7 @@
// Parse the chat message list as well as the log message list
// and display them in chronological order
- int32_t chat_idx = chat_ != nullptr ? chat_->get_messages().size() - 1 : -1;
+ int32_t chat_idx = has_chat_provider() ? chat_->get_messages().size() - 1 : -1;
int32_t log_idx = log_messages_.empty() ? -1 : log_messages_.size() - 1;
std::string richtext;
Follow ups