Do not restart Modest every X minutes
[modest] / src / widgets / modest-window-mgr.c
index cb28697..fa198e3 100644 (file)
@@ -538,16 +538,25 @@ modest_window_mgr_register_window (ModestWindowMgr *self,
                                   ModestWindow *window,
                                   ModestWindow *parent)
 {
-       /* If this is the first registered window then reset the
-          status of the TnyDevice as it might be forced to be offline
-          when modest is running in the background (see
-          modest_tny_account_store_new()) */
-       if (modest_window_mgr_get_num_windows (self) == 0) {
+       gboolean no_windows, retval;
+
+       no_windows = (modest_window_mgr_get_num_windows (self) == 0);
+
+       retval = MODEST_WINDOW_MGR_GET_CLASS (self)->register_window (self, window, parent);
+
+       if  (no_windows) {
+               /* If this is the first registered window then reset the
+                  status of the TnyDevice as it might be forced to be offline
+                  when modest is running in the background (see
+                  modest_tny_account_store_new()) */
                if (tny_device_is_forced (modest_runtime_get_device ()))
                        tny_device_reset (modest_runtime_get_device ());
-       }
 
-       return MODEST_WINDOW_MGR_GET_CLASS (self)->register_window (self, window, parent);
+               /* Do also allow modest to shutdown when the
+                  application is closed */
+               modest_runtime_set_allow_shutdown (TRUE);
+       }
+       return retval;
 }
 
 static gboolean
@@ -587,7 +596,7 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self,
                        (MODEST_MSG_VIEW_WINDOW (window));
 
                MODEST_DEBUG_BLOCK(g_debug ("registering window for %s", uid ? uid : "<none>"););
-               
+
                if (has_uid (priv->preregistered_uids, uid)) {
                        priv->preregistered_uids = 
                                remove_uid (priv->preregistered_uids,
@@ -597,7 +606,7 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self,
        } else if (MODEST_IS_MSG_EDIT_WINDOW(window)) {
                const gchar *uid = modest_msg_edit_window_get_message_uid
                        (MODEST_MSG_EDIT_WINDOW (window));
-               
+
                MODEST_DEBUG_BLOCK(g_debug ("registering window for %s", uid););
 
                priv->preregistered_uids =