diff --git a/src/history_window.py b/src/history_window.py
index f53896c2f5d91187968b041922b2962d457933ee..5e66d7c5f339aaa006c81a8b4539e9d16d915f85 100644
--- a/src/history_window.py
+++ b/src/history_window.py
@@ -307,6 +307,8 @@ class HistoryWindow:
 			self.window.set_title(title)
 
 	def on_calendar_day_selected(self, widget):
+		if not self.jid:
+			return
 		year, month, day = widget.get_date() # integers
 		month = gtkgui_helpers.make_gtk_month_python_month(month)
 		self._add_lines_for_date(year, month, day)
@@ -581,4 +583,4 @@ class HistoryWindow:
 			self._load_history(jid, account)
 		self.results_window.set_property('visible', False)
 
-# vim: se ts=3:
\ No newline at end of file
+# vim: se ts=3: