diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-03-01 22:16:20 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-03-01 22:16:20 +0000 |
| commit | c4a09144149f9a435c271e133ab19546680c273e (patch) | |
| tree | 0ed4007da8302d14f7d4a91c53794f5715d41c8d /src/ui | |
| parent | update to trunk (diff) | |
| parent | Fix for crash when cycle-selecting. (diff) | |
| download | inkscape-c4a09144149f9a435c271e133ab19546680c273e.tar.gz inkscape-c4a09144149f9a435c271e133ab19546680c273e.zip | |
update to trunk
(bzr r11950.1.263)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/tools/dropper-tool.cpp | 4 | ||||
| -rw-r--r-- | src/ui/tools/select-tool.cpp | 66 | ||||
| -rw-r--r-- | src/ui/tools/select-tool.h | 1 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 18 |
4 files changed, 46 insertions, 43 deletions
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index e9e2d6c39..99d42a211 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -336,6 +336,10 @@ bool DropperTool::root_handler(GdkEvent* event) { if (prefs->getBool("/tools/dropper/onetimepick", false)) { prefs->setBool("/tools/dropper/onetimepick", false); sp_toggle_dropper(desktop); + + // sp_toggle_dropper will delete ourselves. + // Thus, make sure we return immediately. + return true; } ret = TRUE; diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index 85bc3fd4a..83bef17c9 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -125,7 +125,6 @@ SelectTool::SelectTool() //static bool within_tolerance = false; static bool is_cycling = false; static bool moved_while_cycling = false; -ToolBase *prev_event_context = NULL; SelectTool::~SelectTool() { @@ -441,24 +440,20 @@ void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *sele } } +void SelectTool::sp_select_context_reset_opacities() { + for (GList *l = this->cycling_items; l != NULL; l = g_list_next(l)) { + Inkscape::DrawingItem *arenaitem = SP_ITEM(l->data)->get_arenaitem(this->desktop->dkey); + arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(SP_ITEM(l->data)->style->opacity.value)); + } -static void -sp_select_context_reset_opacities(ToolBase *event_context) -{ - // SPDesktop *desktop = event_context->desktop; - SelectTool *sc = SP_SELECT_CONTEXT(event_context); - Inkscape::DrawingItem *arenaitem; - for (GList *l = sc->cycling_items; l != NULL; l = g_list_next(l)) { - arenaitem = SP_ITEM(l->data)->get_arenaitem(event_context->desktop->dkey); - arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(SP_ITEM(l->data)->style->opacity.value)); - } - g_list_free(sc->cycling_items); - g_list_free(sc->cycling_items_selected_before); - g_list_free(sc->cycling_items_cmp); - sc->cycling_items = NULL; - sc->cycling_items_selected_before = NULL; - sc->cycling_cur_item = NULL; - sc->cycling_items_cmp = NULL; + g_list_free(this->cycling_items); + g_list_free(this->cycling_items_selected_before); + g_list_free(this->cycling_items_cmp); + + this->cycling_items = NULL; + this->cycling_items_selected_before = NULL; + this->cycling_cur_item = NULL; + this->cycling_items_cmp = NULL; } bool SelectTool::root_handler(GdkEvent* event) { @@ -545,11 +540,9 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_MOTION_NOTIFY: { - if (is_cycling) - { - moved_while_cycling = true; - prev_event_context = this; - } + if (is_cycling) { + moved_while_cycling = true; + } tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); @@ -811,14 +804,12 @@ bool SelectTool::root_handler(GdkEvent* event) { GdkEventScroll *scroll_event = (GdkEventScroll*) event; if (scroll_event->state & GDK_MOD1_MASK) { // alt modified pressed - if (moved_while_cycling) - { - moved_while_cycling = false; - sp_select_context_reset_opacities(prev_event_context); - prev_event_context = NULL; - } + if (moved_while_cycling) { + moved_while_cycling = false; + this->sp_select_context_reset_opacities(); + } - is_cycling = true; + is_cycling = true; bool shift_pressed = scroll_event->state & GDK_SHIFT_MASK; @@ -1205,18 +1196,15 @@ bool SelectTool::root_handler(GdkEvent* event) { Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_RECT); } } else { - if (alt) { // TODO: Should we have a variable like is_cycling or is it harmless to run this piece of code each time? + if (alt) { // quit cycle-selection and reset opacities - if (is_cycling) - { - sp_select_context_reset_opacities(this); - is_cycling = false; - } - + if (is_cycling) { + this->sp_select_context_reset_opacities(); + is_cycling = false; + } } } - } // set cursor to default. if (!desktop->isWaitingCursor()) { // Do we need to reset the cursor here on key release ? @@ -1224,7 +1212,7 @@ bool SelectTool::root_handler(GdkEvent* event) { //gdk_window_set_cursor(window, event_context->cursor); } break; - + } default: break; } diff --git a/src/ui/tools/select-tool.h b/src/ui/tools/select-tool.h index 81763e8b1..edc4069a2 100644 --- a/src/ui/tools/select-tool.h +++ b/src/ui/tools/select-tool.h @@ -64,6 +64,7 @@ public: private: bool sp_select_context_abort(); void sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed); + void sp_select_context_reset_opacities(); }; } diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index dc10e9388..99b72c386 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -739,10 +739,12 @@ bool ToolBase::root_handler(GdkEvent* event) { if (within_tolerance == true) { // Space was pressed, but not panned sp_toggle_selector(desktop); - ret = TRUE; + + // Be careful, sp_toggle_selector will delete ourselves. + // Thus, make sure we return immediately. + return true; } - within_tolerance = false; break; case GDK_KEY_Q: @@ -975,10 +977,18 @@ gint sp_event_context_root_handler(ToolBase * event_context, gint sp_event_context_virtual_root_handler(ToolBase * event_context, GdkEvent * event) { gint ret = false; + if (event_context) { - ret = event_context->root_handler(event); - set_event_location(event_context->desktop, event); + // The root handler also handles pressing the space key. + // This will toggle the current tool and delete the current one. + // Thus, save a pointer to the desktop before calling it. + SPDesktop* desktop = event_context->desktop; + + ret = event_context->root_handler(event); + + set_event_location(desktop, event); } + return ret; } |
