- tmp = (gulong *) g_hash_table_lookup (priv->viewer_handlers, window);
- g_signal_handler_disconnect (window, *tmp);
- g_hash_table_remove (priv->viewer_handlers, window);
+ /* If the viewer was created without a main window
+ (for example when opening a message through D-Bus
+ the viewer handlers was not registered */
+ if (tmp) {
+ g_signal_handler_disconnect (window, *tmp);
+ g_hash_table_remove (priv->viewer_handlers, window);
+ }