Code

Stop overrun.
[inkscape.git] / src / desktop.cpp
index b1b9a29558733ebb207aab2f691af3950814d2f5..1fdad010fb331493e16c679f42ac5c7affae8de7 100644 (file)
@@ -91,8 +91,7 @@
 #include "widgets/desktop-widget.h"
 #include "box3d-context.h"
 
-// TODO those includes are only for the braindead quick zoom implementation.
-// Remove them after fixing this.
+// TODO those includes are only for node tool quick zoom. Remove them after fixing it.
 #include "ui/tool/node-tool.h"
 #include "ui/tool/control-point-selection.h"
 
@@ -463,6 +462,9 @@ void SPDesktop::displayModeToggle() {
         _setDisplayMode(Inkscape::RENDERMODE_OUTLINE);
         break;
     case Inkscape::RENDERMODE_OUTLINE:
+        _setDisplayMode(Inkscape::RENDERMODE_NORMAL);
+        break;
+//    case Inkscape::RENDERMODE_PRINT_COLORS_PREVIEW:
     default:
         _setDisplayMode(Inkscape::RENDERMODE_NORMAL);
     }
@@ -607,8 +609,10 @@ SPDesktop::change_document (SPDocument *theDocument)
     Gtk::Window *parent = this->getToplevel();
     g_assert(parent != NULL);
     SPDesktopWidget *dtw = (SPDesktopWidget *) parent->get_data("desktopwidget");
-    if (dtw) dtw->desktop = this;
-    sp_desktop_widget_update_namedview(dtw);
+    if (dtw) {
+        dtw->desktop = this;
+    }
+    dtw->updateNamedview();
 
     _namedview_modified (namedview, SP_OBJECT_MODIFIED_FLAG, this);
     _document_replaced_signal.emit (this, theDocument);
@@ -632,9 +636,15 @@ SPDesktop::set_event_context (GtkType type, const gchar *config)
         event_context = next;
     }
 
+    // The event_context will be null. This means that it will be impossible
+    // to process any event invoked by the lines below. See for example bug
+    // LP #622350. Cutting and undoing again in the node tool resets the event
+    // context to the node tool. In this bug the line bellow invokes GDK_LEAVE_NOTIFY
+    // events which cannot be handled and must be discarded.
     ec = sp_event_context_new (type, this, config, SP_EVENT_CONTEXT_STATIC);
     ec->next = event_context;
     event_context = ec;
+    // Now the event_context has been set again and we can process all events again
     sp_event_context_activate (ec);
     _event_context_changed_signal.emit (this, ec);
 }
@@ -894,9 +904,8 @@ SPDesktop::zoom_quick (bool enable)
         _quick_zoom_stored_area = get_display_area();
         bool zoomed = false;
 
-        // TODO This is brain damage. This needs to migrate into the node tool,
-        // but currently the design of this method is sufficiently broken
-        // to prevent this.
+        // TODO This needs to migrate into the node tool, but currently the design
+        // of this method is sufficiently wrong to prevent this.
         if (!zoomed && INK_IS_NODE_TOOL(event_context)) {
             InkNodeTool *nt = static_cast<InkNodeTool*>(event_context);
             if (!nt->_selected_nodes->empty()) {
@@ -907,7 +916,7 @@ SPDesktop::zoom_quick (bool enable)
                 if (!Geom::are_near(area, 0) && area * 2.0 < _quick_zoom_stored_area.area()) {
                     set_display_area(nodes, true);
                     zoomed = true;
-               }
+                }
             }
         }
 
@@ -1364,7 +1373,7 @@ SPDesktop::emitToolSubselectionChanged(gpointer data)
 void
 SPDesktop::updateNow()
 {
-  sp_canvas_update_now(canvas);
+    sp_canvas_update_now(canvas);
 }
 
 void
@@ -1632,7 +1641,7 @@ static void
 _reconstruction_start (SPDesktop * desktop)
 {
     // printf("Desktop, starting reconstruction\n");
-    desktop->_reconstruction_old_layer_id = g_strdup(SP_OBJECT_ID(desktop->currentLayer()));
+    desktop->_reconstruction_old_layer_id = g_strdup(desktop->currentLayer()->getId());
     desktop->_layer_hierarchy->setBottom(desktop->currentRoot());
 
     /*