Code

Avoid crash by uninitialized perspectives.
[inkscape.git] / src / event-context.cpp
index b1cfac518ba87c801cf3aee994161ac1b33af4cb..918e3d4194cdb57baff49f51109aca5a7556e7fb 100644 (file)
@@ -174,7 +174,7 @@ sp_event_context_dispose(GObject *object)
     }
 
     if (ec->_delayed_snap_event) {
-       delete ec->_delayed_snap_event;
+        delete ec->_delayed_snap_event;
     }
 
     G_OBJECT_CLASS(parent_class)->dispose(object);
@@ -374,6 +374,8 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
             switch (event->button.button) {
                 case 1:
                     if (event_context->space_panning) {
+                        // When starting panning, make sure there are no snap events pending because these might disable the panning again
+                        sp_event_context_discard_delayed_snap_event(event_context);
                         panning = 1;
                         sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                             GDK_KEY_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
@@ -382,9 +384,11 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                     }
                     break;
                 case 2:
-                    if (event->button.state == GDK_SHIFT_MASK) {
+                    if (event->button.state & GDK_SHIFT_MASK) {
                         zoom_rb = 2;
                     } else {
+                        // When starting panning, make sure there are no snap events pending because these might disable the panning again
+                        sp_event_context_discard_delayed_snap_event(event_context);
                         panning = 2;
                         sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                             GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
@@ -395,6 +399,8 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                 case 3:
                     if (event->button.state & GDK_SHIFT_MASK
                             || event->button.state & GDK_CONTROL_MASK) {
+                        // When starting panning, make sure there are no snap events pending because these might disable the panning again
+                        sp_event_context_discard_delayed_snap_event(event_context);
                         panning = 3;
                         sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
                                 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK,
@@ -508,11 +514,11 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
             }
             break;
         case GDK_KEY_PRESS:
-               {
-               double const acceleration = prefs->getDoubleLimited("/options/scrollingacceleration/value", 0, 0, 6);
-               int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", 10, 0, 1000);
+            {
+            double const acceleration = prefs->getDoubleLimited("/options/scrollingacceleration/value", 0, 0, 6);
+            int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", 10, 0, 1000);
 
-               switch (get_group0_keyval(&event->key)) {
+            switch (get_group0_keyval(&event->key)) {
                 // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets
                 // in the editing window). So we resteal them back and run our regular shortcut
                 // invoker on them.
@@ -539,11 +545,11 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                     break;
                 case GDK_Q:
                 case GDK_q:
-                                       if (desktop->quick_zoomed()) {
-                                               ret = TRUE;
-                                       }
+                    if (desktop->quick_zoomed()) {
+                        ret = TRUE;
+                    }
                     if (!MOD__SHIFT && !MOD__CTRL && !MOD__ALT) {
-                                               desktop->zoom_quick(true);
+                        desktop->zoom_quick(true);
                         ret = TRUE;
                     }
                     break;
@@ -626,7 +632,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                 default:
                     break;
             }
-               }
+            }
             break;
         case GDK_KEY_RELEASE:
             switch (get_group0_keyval(&event->key)) {
@@ -645,8 +651,8 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
                     break;
                 case GDK_Q:
                 case GDK_q:
-                                       if (desktop->quick_zoomed()) {
-                                               desktop->zoom_quick(false);
+                    if (desktop->quick_zoomed()) {
+                        desktop->zoom_quick(false);
                         ret = TRUE;
                     }
                     break;
@@ -874,9 +880,8 @@ sp_event_context_activate(SPEventContext *ec)
 
     // Make sure no delayed snapping events are carried over after switching contexts
     // (this is only an additional safety measure against sloppy coding, because each
-    // context should take care of this by itself. It might be hard to get each and every
-    // context perfect though)
-    sp_event_context_snap_window_closed(ec, false);
+    // context should take care of this by itself.
+    sp_event_context_discard_delayed_snap_event(ec);
 
     if (((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate)
         ((SPEventContextClass *) G_OBJECT_GET_CLASS(ec))->activate(ec);
@@ -901,26 +906,25 @@ sp_event_context_deactivate(SPEventContext *ec)
 gint
 sp_event_context_root_handler(SPEventContext * event_context, GdkEvent * event)
 {
-    //std::cout << "sp_event_context_root_handler" << std::endl;
-       switch (event->type) {
-               case GDK_MOTION_NOTIFY:
-                       sp_event_context_snap_delay_handler(event_context, NULL, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER);
-                       break;
-               case GDK_BUTTON_RELEASE:
-                       if (event_context->_delayed_snap_event) {
-                               // If we have any pending snapping action, then invoke it now
-                               sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
-                       }
-                       break;
-               case GDK_BUTTON_PRESS:
+    switch (event->type) {
+        case GDK_MOTION_NOTIFY:
+            sp_event_context_snap_delay_handler(event_context, NULL, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER);
+            break;
+        case GDK_BUTTON_RELEASE:
+            if (event_context->_delayed_snap_event) {
+                // If we have any pending snapping action, then invoke it now
+                sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
+            }
+            break;
+        case GDK_BUTTON_PRESS:
         case GDK_2BUTTON_PRESS:
         case GDK_3BUTTON_PRESS:
-                       // Snapping will be on hold if we're moving the mouse at high speeds. When starting
-                       // drawing a new shape we really should snap though.
-                       event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
-                       break;
+            // Snapping will be on hold if we're moving the mouse at high speeds. When starting
+            // drawing a new shape we really should snap though.
+            event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
+            break;
         default:
-               break;
+            break;
     }
 
     return sp_event_context_virtual_root_handler(event_context, event);
@@ -929,11 +933,9 @@ sp_event_context_root_handler(SPEventContext * event_context, GdkEvent * event)
 gint
 sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEvent * event)
 {
-       //std::cout << "sp_event_context_virtual_root_handler -> postponed: " << event_context->desktop->namedview->snap_manager.snapprefs.getSnapPostponedGlobally() << std::endl;
-
-       gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event);
-       set_event_location(event_context->desktop, event);
-       return ret;
+    gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->root_handler(event_context, event);
+    set_event_location(event_context->desktop, event);
+    return ret;
 }
 
 /**
@@ -942,28 +944,27 @@ sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEvent *
 gint
 sp_event_context_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event)
 {
-       //std::cout << "sp_event_context_item_handler" << std::endl;
-       switch (event->type) {
-               case GDK_MOTION_NOTIFY:
-                       sp_event_context_snap_delay_handler(event_context, item, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER);
-                       break;
-               case GDK_BUTTON_RELEASE:
-                       if (event_context->_delayed_snap_event) {
-                               // If we have any pending snapping action, then invoke it now
-                               sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
-                       }
-                       break;
-               /*case GDK_BUTTON_PRESS:
-               case GDK_2BUTTON_PRESS:
-               case GDK_3BUTTON_PRESS:
-                       // Snapping will be on hold if we're moving the mouse at high speeds. When starting
-                       // drawing a new shape we really should snap though.
-                       event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
-                       break;
-               */
-               default:
-                       break;
-       }
+    switch (event->type) {
+        case GDK_MOTION_NOTIFY:
+            sp_event_context_snap_delay_handler(event_context, item, NULL, (GdkEventMotion *)event, DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER);
+            break;
+        case GDK_BUTTON_RELEASE:
+            if (event_context->_delayed_snap_event) {
+                // If we have any pending snapping action, then invoke it now
+                sp_event_context_snap_watchdog_callback(event_context->_delayed_snap_event);
+            }
+            break;
+        /*case GDK_BUTTON_PRESS:
+        case GDK_2BUTTON_PRESS:
+        case GDK_3BUTTON_PRESS:
+            // Snapping will be on hold if we're moving the mouse at high speeds. When starting
+            // drawing a new shape we really should snap though.
+            event_context->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
+            break;
+        */
+        default:
+            break;
+    }
 
     return sp_event_context_virtual_item_handler(event_context, item, event);
 }
@@ -971,15 +972,15 @@ sp_event_context_item_handler(SPEventContext * event_context, SPItem * item, Gdk
 gint
 sp_event_context_virtual_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event)
 {
-       gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event);
+    gint ret = ((SPEventContextClass *) G_OBJECT_GET_CLASS(event_context))->item_handler(event_context, item, event);
 
-       if (! ret) {
-               ret = sp_event_context_virtual_root_handler(event_context, event);
-       } else {
-               set_event_location(event_context->desktop, event);
-       }
+    if (! ret) {
+        ret = sp_event_context_virtual_root_handler(event_context, event);
+    } else {
+        set_event_location(event_context->desktop, event);
+    }
 
-       return ret;
+    return ret;
 }
 
 /**
@@ -1173,166 +1174,124 @@ event_context_print_event_info(GdkEvent *event, bool print_return) {
 
 void sp_event_context_snap_delay_handler(SPEventContext *ec, SPItem* const item, SPKnot* const knot, GdkEventMotion *event, DelayedSnapEvent::DelayedSnapEventOrigin origin)
 {
-       static guint32 prev_time;
-       static boost::optional<Geom::Point> prev_pos;
+    static guint32 prev_time;
+    static boost::optional<Geom::Point> prev_pos;
 
-       // Snapping occurs when dragging with the left mouse button down, or when hovering e.g. in the pen tool with left mouse button up
+    // Snapping occurs when dragging with the left mouse button down, or when hovering e.g. in the pen tool with left mouse button up
     bool const c1 = event->state & GDK_BUTTON2_MASK; // We shouldn't hold back any events when other mouse buttons have been
     bool const c2 = event->state & GDK_BUTTON3_MASK; // pressed, e.g. when scrolling with the middle mouse button; if we do then
-                                                                                                    // Inkscape will get stuck in an unresponsive state
-
-    if (c1 || c2) {
-       // Make sure that we don't send any pending snap events to a context if we know in advance
-       // that we're not going to snap any way (e.g. while scrolling with middle mouse button)
-       // Any motion event might affect the state of the context, leading to unexpected behavior
-       delete ec->_delayed_snap_event;
-       ec->_delayed_snap_event = NULL;
-    }
+                                                     // Inkscape will get stuck in an unresponsive state
+    bool const c3 = tools_isactive(ec->desktop, TOOLS_CALLIGRAPHIC);
+                                                     // The snap delay will repeat the last motion event, which will lead to
+                                                     // erroneous points in the calligraphy context. And because we don't snap
+                                                     // in this context, we might just as well disable the snap delay all together
+    if (c1 || c2 || c3) {
+        // Make sure that we don't send any pending snap events to a context if we know in advance
+        // that we're not going to snap any way (e.g. while scrolling with middle mouse button)
+        // Any motion event might affect the state of the context, leading to unexpected behavior
+        sp_event_context_discard_delayed_snap_event(ec);
+    } else if (ec->desktop && ec->desktop->namedview->snap_manager.snapprefs.getSnapEnabledGlobally()) {
+        // Snap when speed drops below e.g. 0.02 px/msec, or when no motion events have occurred for some period.
+        // i.e. snap when we're at stand still. A speed threshold enforces snapping for tablets, which might never
+        // be fully at stand still and might keep spitting out motion events.
+        ec->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(true); // put snapping on hold
+
+        Geom::Point event_pos(event->x, event->y);
+        guint32 event_t = gdk_event_get_time ( (GdkEvent *) event );
+
+        if (prev_pos) {
+            Geom::Coord dist = Geom::L2(event_pos - *prev_pos);
+            guint32 delta_t = event_t - prev_time;
+            gdouble speed = delta_t > 0 ? dist/delta_t : 1000;
+            //std::cout << "Mouse speed = " << speed << " px/msec " << std::endl;
+            if (speed > 0.02) { // Jitter threshold, might be needed for tablets
+                // We're moving fast, so postpone any snapping until the next GDK_MOTION_NOTIFY event. We
+                // will keep on postponing the snapping as long as the speed is high.
+                // We must snap at some point in time though, so set a watchdog timer at some time from
+                // now, just in case there's no future motion event that drops under the speed limit (when
+                // stopping abruptly)
+                delete ec->_delayed_snap_event;
+                ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin); // watchdog is reset, i.e. pushed forward in time
+                // If the watchdog expires before a new motion event is received, we will snap (as explained
+                // above). This means however that when the timer is too short, we will always snap and that the
+                // speed threshold is ineffective. In the extreme case the delay is set to zero, and snapping will
+                // be immediate, as it used to be in the old days ;-).
+            } else { // Speed is very low, so we're virtually at stand still
+                // But if we're really standing still, then we should snap now. We could use some low-pass filtering,
+                // otherwise snapping occurs for each jitter movement. For this filtering we'll leave the watchdog to expire,
+                // snap, and set a new watchdog again.
+                if (ec->_delayed_snap_event == NULL) { // no watchdog has been set
+                    // it might have already expired, so we'll set a new one; the snapping frequency will be limited this way
+                    ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
+                } // else: watchdog has been set before and we'll wait for it to expire
+            }
+        } else {
+            // This is the first GDK_MOTION_NOTIFY event, so postpone snapping and set the watchdog
+            g_assert(ec->_delayed_snap_event == NULL);
+            ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
+        }
 
-    if (ec->_snap_window_open && !c1 && !c2 && ec->desktop && ec->desktop->namedview->snap_manager.snapprefs.getSnapEnabledGlobally()) {
-       // Snap when speed drops below e.g. 0.02 px/msec, or when no motion events have occurred for some period.
-               // i.e. snap when we're at stand still. A speed threshold enforces snapping for tablets, which might never
-               // be fully at stand still and might keep spitting out motion events.
-       ec->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(true); // put snapping on hold
-
-       Geom::Point event_pos(event->x, event->y);
-               guint32 event_t = gdk_event_get_time ( (GdkEvent *) event );
-
-               if (prev_pos) {
-                       Geom::Coord dist = Geom::L2(event_pos - *prev_pos);
-                       guint32 delta_t = event_t - prev_time;
-                       gdouble speed = delta_t > 0 ? dist/delta_t : 1000;
-                       //std::cout << "Mouse speed = " << speed << " px/msec " << std::endl;
-                       if (speed > 0.02) { // Jitter threshold, might be needed for tablets
-                               // We're moving fast, so postpone any snapping until the next GDK_MOTION_NOTIFY event. We
-                               // will keep on postponing the snapping as long as the speed is high.
-                               // We must snap at some point in time though, so set a watchdog timer at some time from
-                               // now, just in case there's no future motion event that drops under the speed limit (when
-                               // stopping abruptly)
-                               delete ec->_delayed_snap_event;
-                               ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin); // watchdog is reset, i.e. pushed forward in time
-                               // If the watchdog expires before a new motion event is received, we will snap (as explained
-                               // above). This means however that when the timer is too short, we will always snap and that the
-                               // speed threshold is ineffective. In the extreme case the delay is set to zero, and snapping will
-                               // be immediate, as it used to be in the old days ;-).
-                       } else { // Speed is very low, so we're virtually at stand still
-                               // But if we're really standing still, then we should snap now. We could use some low-pass filtering,
-                               // otherwise snapping occurs for each jitter movement. For this filtering we'll leave the watchdog to expire,
-                               // snap, and set a new watchdog again.
-                               if (ec->_delayed_snap_event == NULL) { // no watchdog has been set
-                                       // it might have already expired, so we'll set a new one; the snapping frequency will be limited by this
-                                       ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
-                               } // else: watchdog has been set before and we'll wait for it to expire
-                       }
-               } else {
-                       // This is the first GDK_MOTION_NOTIFY event, so postpone snapping and set the watchdog
-                       g_assert(ec->_delayed_snap_event == NULL);
-                       ec->_delayed_snap_event = new DelayedSnapEvent(ec, item, knot, event, origin);
-               }
-
-               prev_pos = event_pos;
-               prev_time = event_t;
-       }
+        prev_pos = event_pos;
+        prev_time = event_t;
+    }
 }
 
 gboolean sp_event_context_snap_watchdog_callback(gpointer data)
 {
-       // Snap NOW! For this the "postponed" flag will be reset and the last motion event will be repeated
-       DelayedSnapEvent *dse = reinterpret_cast<DelayedSnapEvent*>(data);
-
-       if (dse == NULL) {
-               // This might occur when this method is called directly, i.e. not through the timer
-               // E.g. on GDK_BUTTON_RELEASE in sp_event_context_root_handler()
-               return FALSE;
-       }
-
-       SPEventContext *ec = dse->getEventContext();
-       if (ec == NULL || ec->desktop == NULL) {
-               return false;
-       }
-
-       SPDesktop *dt = ec->desktop;
-       dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
-
-       switch (dse->getOrigin()) {
-               case DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER:
-                       sp_event_context_virtual_root_handler(ec, dse->getEvent());
-                       break;
-               case DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER:
-                       {
-                               SPItem* item = NULL;
-                               item = dse->getItem();
-                               if (item && SP_IS_ITEM(item)) {
-                                       sp_event_context_virtual_item_handler(ec, item, dse->getEvent());
-                               }
-                       }
-                       break;
-               case DelayedSnapEvent::KNOT_HANDLER:
-                       {
-                               SPKnot* knot = dse->getKnot();
-                               if (knot && SP_IS_KNOT(knot)) {
-                                       sp_knot_handler_request_position(dse->getEvent(), knot);
-                               }
-                       }
-                       break;
-               default:
-                       g_warning("Origin of snap-delay event has not been defined!;");
-                       break;
-       }
-
-       ec->_delayed_snap_event = NULL;
-       delete dse;
-
-       return FALSE; //Kills the timer and stops it from executing this callback over and over again.
-}
+    // Snap NOW! For this the "postponed" flag will be reset and the last motion event will be repeated
+    DelayedSnapEvent *dse = reinterpret_cast<DelayedSnapEvent*>(data);
 
-void sp_event_context_snap_window_open(SPEventContext *ec, bool show_debug_warnings)
-{
-       // Only when ec->_snap_window_open has been set, Inkscape will know that snapping is active
-       // and will delay any snapping events (but only when asked to through the preferences)
-
-       // When snapping is being delayed, then that will also mean that at some point the last event
-       // might be re-triggered. This should only occur when Inkscape is still in the same tool or context,
-       // and even more specifically, the tool should even be in the same state. If for example snapping is being delayed while
-       // creating a rectangle, then the rect-context will be active and it will be in the "dragging" state
-       // (see the static boolean variable "dragging" in the sp_rect_context_root_handler). The procedure is
-       // as follows: call sp_event_context_snap_window_open(*, TRUE) when entering the "dragging" state, which will delay
-       // snapping from that moment on, and call sp_event_context_snap_window_open(*, FALSE) when leaving the "dragging"
-       // state. This last call will also make sure that any pending snap events will be canceled.
-
-       //std::cout << "sp_event_context_snap_window_open" << std::endl;
-       if (!ec) {
-               if (show_debug_warnings) {
-                       g_warning("sp_event_context_snap_window_open() has been called without providing an event context!");
-               }
-               return;
-       }
-
-       if (ec->_snap_window_open == true && show_debug_warnings) {
-               g_warning("Snap window was already open! This is a bug, please report it.");
-       }
-
-       ec->_snap_window_open = true;
+    if (dse == NULL) {
+        // This might occur when this method is called directly, i.e. not through the timer
+        // E.g. on GDK_BUTTON_RELEASE in sp_event_context_root_handler()
+        return FALSE;
+    }
+
+    SPEventContext *ec = dse->getEventContext();
+    if (ec == NULL || ec->desktop == NULL) {
+        return false;
+    }
+
+    SPDesktop *dt = ec->desktop;
+    dt->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
+
+    switch (dse->getOrigin()) {
+        case DelayedSnapEvent::EVENTCONTEXT_ROOT_HANDLER:
+            sp_event_context_virtual_root_handler(ec, dse->getEvent());
+            break;
+        case DelayedSnapEvent::EVENTCONTEXT_ITEM_HANDLER:
+            {
+                SPItem* item = NULL;
+                item = dse->getItem();
+                if (item && SP_IS_ITEM(item)) {
+                    sp_event_context_virtual_item_handler(ec, item, dse->getEvent());
+                }
+            }
+            break;
+        case DelayedSnapEvent::KNOT_HANDLER:
+            {
+                SPKnot* knot = dse->getKnot();
+                if (knot && SP_IS_KNOT(knot)) {
+                    sp_knot_handler_request_position(dse->getEvent(), knot);
+                }
+            }
+            break;
+        default:
+            g_warning("Origin of snap-delay event has not been defined!;");
+            break;
+    }
+
+    ec->_delayed_snap_event = NULL;
+    delete dse;
+
+    return FALSE; //Kills the timer and stops it from executing this callback over and over again.
 }
 
-void sp_event_context_snap_window_closed(SPEventContext *ec, bool show_debug_warnings)
+void sp_event_context_discard_delayed_snap_event(SPEventContext *ec)
 {
-       //std::cout << "sp_event_context_snap_window_closed" << std::endl;
-       if (!ec) {
-               if (show_debug_warnings) {
-                       g_warning("sp_event_context_snap_window_closed() has been called without providing an event context!");
-               }
-               return;
-       }
-
-       if (ec->_snap_window_open == false && show_debug_warnings) {
-               g_warning("Snap window was already closed! This is a bug, please report it.");
-       }
-
-       ec->_snap_window_open = false;
-
-       delete ec->_delayed_snap_event;
-       ec->_delayed_snap_event = NULL;
+    delete ec->_delayed_snap_event;
+    ec->_delayed_snap_event = NULL;
 }