/* cancel open and receive operations */
cancel_window_operations (window);
+ /* Check if it's the topmost window, and remove the window from the stack.
+ * This is needed for the cases there's no other topmost window that will
+ * replace it in topmost handler.
+ */
+ if (window == priv->current_top)
+ priv->current_top = NULL;
+
/* Disconnect the "window-state-event" handler, we won't need it anymore */
if (priv->window_state_uids) {
#ifdef MODEST_PLATFORM_MAEMO
/* Disconnect all the window signals */
modest_window_disconnect_signals (window);
- /* Destroy the window and unref the extra reference */
- g_object_unref (win->data);
+ /* Destroy the window */
gtk_widget_destroy (win->data);
/* If there are no more windows registered emit the signal */