[smuxi] Engine: fixed NullReferenceException thrown in SqliteMessageBuffer.Count (closes: #1022)
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi] Engine: fixed NullReferenceException thrown in SqliteMessageBuffer.Count (closes: #1022)
- Date: Sun, 3 May 2015 21:24:57 +0000 (UTC)
commit b6a0133e0b1a3966c3287d8e4eabd9cff6fa45c5
Author: Mirco Bauer <meebey meebey net>
Date: Sun May 3 23:21:22 2015 +0200
Engine: fixed NullReferenceException thrown in SqliteMessageBuffer.Count (closes: #1022)
There can be a race between SqliteMessageBuffer.Dispose() and .get_Count which
led to this exception:
Server stack trace:
at Smuxi.Engine.SqliteMessageBuffer.get_Count () [0x00000] in
/usr/local/src/smuxi/src/Engine/MessageBuffers/SqliteMessageBuffer.cs:42
at Smuxi.Engine.ChatModel.GetSyncMessages () [0x0000d] in
/usr/local/src/smuxi/src/Engine/Chats/ChatModel.cs:248
at Smuxi.Engine.ChatModel.get_Messages () [0x00000] in
/usr/local/src/smuxi/src/Engine/Chats/ChatModel.cs:82
src/Engine/MessageBuffers/SqliteMessageBuffer.cs | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
b/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
index f156836..cdca285 100644
--- a/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
+++ b/src/Engine/MessageBuffers/SqliteMessageBuffer.cs
@@ -1,6 +1,6 @@
// Smuxi - Smart MUltipleXed Irc
//
-// Copyright (c) 2014 Mirco Bauer <meebey meebey net>
+// Copyright (c) 2014-2015 Mirco Bauer <meebey meebey net>
//
// Full GPL License: <http://www.gnu.org/licenses/gpl.txt>
//
@@ -39,7 +39,11 @@ namespace Smuxi.Engine
public override int Count {
get {
- using (var cmd = Connection.CreateCommand()) {
+ var connection = Connection;
+ if (connection == null) {
+ return 0;
+ }
+ using (var cmd = connection.CreateCommand()) {
cmd.CommandText = "SELECT COUNT(*) FROM Messages";
return (int) Convert.ChangeType(cmd.ExecuteScalar(), typeof(int));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]