← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1513181-chat-overlay into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1513181-chat-overlay into lp:widelands.

Commit message:
Fixed check in ChatOverlay whether a chat provider has been assigned.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1513181 in widelands: "Multiplayer chat don't display any more"
  https://bugs.launchpad.net/widelands/+bug/1513181

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1513181-chat-overlay/+merge/287135

Brought back the chat overlay.

We used to get a crash when an exception was raised while loading a map or game, so we need to check whether the ChatProvider has been set. The check was not correct, so it was always assumed that it was not set.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1513181-chat-overlay into lp:widelands.
=== modified file 'src/chat/chat.h'
--- src/chat/chat.h	2015-06-10 06:46:40 +0000
+++ src/chat/chat.h	2016-02-25 08:52:14 +0000
@@ -75,6 +75,9 @@
 	// TODO(sirver): this does not belong here. The receiver of the
 	// notifications should deal with this.
 	virtual bool sound_off() {return false;}
+
+	// The specific chat provider subclass might not have been set, e.g. due to an exception.
+	virtual bool has_been_set() const {return false;}
 };
 
 #endif  // end of include guard:

=== modified file 'src/network/internet_gaming.h'
--- src/network/internet_gaming.h	2016-02-16 11:43:06 +0000
+++ src/network/internet_gaming.h	2016-02-25 08:52:14 +0000
@@ -124,6 +124,8 @@
 		ingame_system_chat_.clear();
 	}
 
+	bool has_been_set() const override {return true;}
+
 private:
 	InternetGaming();
 

=== modified file 'src/network/netclient.h'
--- src/network/netclient.h	2016-02-14 15:49:59 +0000
+++ src/network/netclient.h	2016-02-25 08:52:14 +0000
@@ -98,6 +98,7 @@
 	// ChatProvider interface
 	void send(const std::string & msg) override;
 	const std::vector<ChatMessage> & get_messages() const override;
+	bool has_been_set() const override {return true;}
 
 private:
 	/// for unique backupname

=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc	2016-02-15 22:31:59 +0000
+++ src/network/nethost.cc	2016-02-25 08:52:14 +0000
@@ -482,6 +482,8 @@
 		Notifications::publish(msg);
 	}
 
+	bool has_been_set() const override {return true;}
+
 private:
 	NetHost                * h;
 	std::vector<ChatMessage> messages;

=== modified file 'src/wui/chatoverlay.cc'
--- src/wui/chatoverlay.cc	2016-01-18 19:35:25 +0000
+++ src/wui/chatoverlay.cc	2016-02-25 08:52:14 +0000
@@ -72,11 +72,9 @@
 
 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;
+		return (chat_ != nullptr && chat_->has_been_set());
 	}
 };
 


References