diff --git a/src/gajim.py b/src/gajim.py
index eebdd6e9aa2d9073b15850be8d6fe1b1095f7ede..d705997a6b6778073b1eeb0fc3929b7f7c52837c 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -430,7 +430,7 @@ class Interface:
 				contact.chatstate = False
 		else:
 			# Brand new message, incoming.  
-			if chatstate == 'active':  
+			if contact and chatstate == 'active':  
 				contact.chatstate = chatstate
 
 		if not array[1]: #empty message text