From 7a1d879ca67e2890e3134f20ebf0041c54e66cb9 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Fri, 2 Jul 2010 20:27:35 +0100
Subject: Don't crash when signing out if the debug console's open.

Resolves: #484

diff --git a/Swift/QtUI/QtChatTabs.cpp b/Swift/QtUI/QtChatTabs.cpp
index 5473823..2f4d2e5 100644
--- a/Swift/QtUI/QtChatTabs.cpp
+++ b/Swift/QtUI/QtChatTabs.cpp
@@ -15,6 +15,7 @@
 #include <QLayout>
 #include <QTabBar>
 #include <QApplication>
+#include <qdebug.h>
 
 namespace Swift {
 QtChatTabs::QtChatTabs() : QWidget() {
@@ -148,7 +149,10 @@ void QtChatTabs::handleTabTitleUpdated(QWidget* widget) {
 	tabs_->tabBar()->setTabTextColor(index, tabTextColor); 
 	int unread = 0;
 	for (int i = 0; i < tabs_->count(); i++) {
-		unread += qobject_cast<QtTabbable*>(tabs_->widget(i))->getCount();
+		QtTabbable* tab = qobject_cast<QtTabbable*>(tabs_->widget(i));
+		if (tab) {
+			unread += tab->getCount(); 
+		}
 	}
 	
 	QtTabbable* current = qobject_cast<QtTabbable*>(tabs_->currentWidget());
-- 
cgit v0.10.2-6-g49f6