[smuxi/stable] Engine: fix NRE in ChatModel.set_LastSeenHighlight and set_LastSeenMessage
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi/stable] Engine: fix NRE in ChatModel.set_LastSeenHighlight and set_LastSeenMessage
- Date: Mon, 27 Mar 2017 14:48:01 +0000 (UTC)
commit 2b5e19bdbd03ced6b0849dfce4e0160835048db5
Author: Mirco Bauer <meebey meebey net>
Date: Mon Mar 27 22:23:06 2017 +0800
Engine: fix NRE in ChatModel.set_LastSeenHighlight and set_LastSeenMessage
If a ChatModel is created but the MessageBuffer is not initialized yet, then
ChatModel.set_LastSeenHighlight and also set_LastSeenMessage will throw a
NullReferenceException like this:
Server stack trace:
at Smuxi.Engine.ChatModel.set_LastSeenHighlight (DateTime value) [0x00000] in
/usr/local/src/smuxi-cloud/src/Engine/Chats/ChatModel.cs:136
at (wrapper managed-to-native) System.Runtime.Remoting.RemotingServices:InternalExecute
(System.Reflection.MethodBase,object,object[],object[]&)
at System.Runtime.Remoting.RemotingServices.InternalExecuteMessage (System.MarshalByRefObject
target, IMethodCallMessage reqMsg) [0x000c2] in
/tmp/buildd/mono-2.10.8.1/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs:138
Exception rethrown at [0]:
at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_remoting_wrapper (intptr,intptr)
at (wrapper remoting-invoke) Smuxi.Engine.ChatModel:set_LastSeenHighlight (System.DateTime)
at (wrapper remoting-invoke-with-check) Smuxi.Engine.ChatModel:set_LastSeenHighlight
(System.DateTime)
at Smuxi.Frontend.Gnome.Notebook+<OnSwitchPage>c__AnonStorey0.<>m__0 () [0x00085] in
/tmp/buildd/smuxi-1.0.6/src/Frontend-GNOME/Notebook.cs:264
This is probably a race condition by an Engine that is creating and pushing a
new chat to the frontend before the chat is fully initialized using
ApplyConfig() or InitMessageBuffer(). Or the MessageBuffer had an error
condition and got reset (to null) using ResetMessageBuffer().
Thus this condition is now handled and logged for debugging purposes.
src/Engine/Chats/ChatModel.cs | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/Engine/Chats/ChatModel.cs b/src/Engine/Chats/ChatModel.cs
index f62e7b7..0777fa6 100644
--- a/src/Engine/Chats/ChatModel.cs
+++ b/src/Engine/Chats/ChatModel.cs
@@ -133,7 +133,18 @@ namespace Smuxi.Engine
return MessageBuffer.LastSeenHighlight;
}
set {
- MessageBuffer.LastSeenHighlight = value;
+ var msgBuffer = MessageBuffer;
+ if (msgBuffer == null) {
+#if LOG4NET
+ _Logger.ErrorFormat(
+ "{0}.set_LastSeenHighlight(): MessageBuffer is null, " +
+ "ignoring set call...",
+ this
+ );
+#endif
+ return;
+ }
+ msgBuffer.LastSeenHighlight = value;
}
}
@@ -145,7 +156,18 @@ namespace Smuxi.Engine
return MessageBuffer.LastSeenMessage;
}
set {
- MessageBuffer.LastSeenMessage = value;
+ var msgBuffer = MessageBuffer;
+ if (msgBuffer == null) {
+#if LOG4NET
+ _Logger.ErrorFormat(
+ "{0}.set_LastSeenMessage(): MessageBuffer is null, " +
+ "ignoring set call...",
+ this
+ );
+#endif
+ return;
+ }
+ msgBuffer.LastSeenMessage = value;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]