From 46e06d5d0d04e6d5e0361efd46687ca2cef4fde8 Mon Sep 17 00:00:00 2001 From: mh17 <mh17> Date: Thu, 10 Jun 2010 14:50:31 +0000 Subject: [PATCH] fixed crash on destroy focus of 3 frame when going revcomp --- src/zmapWindow/zmapWindow.c | 33 ++++++------------ src/zmapWindow/zmapWindowDrawFeatures.c | 4 +-- src/zmapWindow/zmapWindowFeature.c | 5 +-- src/zmapWindow/zmapWindowFocus.c | 46 ++++++++++++------------- 4 files changed, 38 insertions(+), 50 deletions(-) diff --git a/src/zmapWindow/zmapWindow.c b/src/zmapWindow/zmapWindow.c index 43db6e504..0d9937a49 100755 --- a/src/zmapWindow/zmapWindow.c +++ b/src/zmapWindow/zmapWindow.c @@ -26,9 +26,9 @@ * * Exported functions: See ZMap/zmapWindow.h * HISTORY: - * Last edited: Jun 9 17:35 2010 (edgrif) + * Last edited: May 24 16:04 2010 (edgrif) * Created: Thu Jul 24 14:36:27 2003 (edgrif) - * CVS info: $Id: zmapWindow.c,v 1.324 2010-06-09 16:45:01 edgrif Exp $ + * CVS info: $Id: zmapWindow.c,v 1.325 2010-06-10 14:50:31 mh17 Exp $ *------------------------------------------------------------------- */ @@ -288,7 +288,7 @@ static gboolean window_split_save_bumped_G = TRUE; /* Debugging canvas... */ static gboolean busy_debug_G = FALSE ; static gboolean foo_debug_G = FALSE ; -static gboolean mouse_debug_G = TRUE ; +static gboolean mouse_debug_G = FALSE ; @@ -2053,7 +2053,12 @@ static void resetCanvas(ZMapWindow window, gboolean free_child_windows, gboolean zmapWindowFreeWindowArray(&(window->feature_show_windows), FALSE) ; } - if (window->feature_root_group) + // destroy focus before the canvas items via + // zmapWindowContainerGroupDestroy(window->feature_root_group) + zmapWindowFocusDestroy(window->focus) ; + window->focus = NULL; + + if (window->feature_root_group) { /* Reset mark object, must come before root group etc. is destroyed as we need to remove * various canvas items. */ @@ -2094,7 +2099,7 @@ static void resetCanvas(ZMapWindow window, gboolean free_child_windows, gboolean /* Recreate focus object. */ - zmapWindowFocusDestroy(window->focus) ; +// zmapWindowFocusDestroy(window->focus) ; window->focus = zmapWindowFocusCreate() ; return ; @@ -2786,9 +2791,6 @@ static gboolean canvasWindowEventCB(GtkWidget *widget, GdkEvent *event, gpointer case 1: { - /* let's try simuulating the enter.... */ - in_window = TRUE ; - if (but_event->send_event) { /* If we receive a button press event where send_event == TRUE, its the one we sent ourselves @@ -3109,8 +3111,6 @@ static gboolean canvasWindowEventCB(GtkWidget *widget, GdkEvent *event, gpointer if (dragging) { - zMapDebugPrint(mouse_debug_G, "button_release %d - in dragging !!", but_event->button) ; - foo_canvas_item_hide(window->rubberband); /* mouse must still be within window to zoom, outside means user is cancelling motion, @@ -3135,9 +3135,6 @@ static gboolean canvasWindowEventCB(GtkWidget *widget, GdkEvent *event, gpointer } event_handled = TRUE; /* We _ARE_ handling */ - - zMapDebugPrint(mouse_debug_G, "button_release %d - not resending event !!", but_event->button) ; - } else { @@ -3159,19 +3156,11 @@ static gboolean canvasWindowEventCB(GtkWidget *widget, GdkEvent *event, gpointer event_handled = FALSE ; } } - else - { - zMapDebugPrint(mouse_debug_G, "button_release %d - not in window !!", but_event->button) ; - - } dragging = FALSE ; } else if (guide) { - zMapDebugPrint(mouse_debug_G, "button_release %d - in guide !!", but_event->button) ; - - /* If we are a locked, _vertical_ split window then also show the ruler in the * other windows. */ if (locked) @@ -3212,8 +3201,6 @@ static gboolean canvasWindowEventCB(GtkWidget *widget, GdkEvent *event, gpointer } else if(mark_updater.activated) { - zMapDebugPrint(mouse_debug_G, "button_release %d - in mark !!", but_event->button) ; - mark_updater.activated = FALSE; mark_updater.in_mark_move_region = FALSE; diff --git a/src/zmapWindow/zmapWindowDrawFeatures.c b/src/zmapWindow/zmapWindowDrawFeatures.c index 962444650..920f75ffb 100755 --- a/src/zmapWindow/zmapWindowDrawFeatures.c +++ b/src/zmapWindow/zmapWindowDrawFeatures.c @@ -28,7 +28,7 @@ * HISTORY: * Last edited: Mar 11 14:19 2010 (edgrif) * Created: Thu Jul 29 10:45:00 2004 (rnc) - * CVS info: $Id: zmapWindowDrawFeatures.c,v 1.275 2010-06-10 10:35:28 mh17 Exp $ + * CVS info: $Id: zmapWindowDrawFeatures.c,v 1.276 2010-06-10 14:50:31 mh17 Exp $ *------------------------------------------------------------------- */ @@ -2585,7 +2585,7 @@ static gboolean containerDestroyCB(FooCanvasItem *item, gpointer user_data) container_set->frame) ; /* If the focus column goes then so should the focus items as they should be in step. */ - if (zmapWindowFocusGetHotColumn(window->focus) == group) + if (window->focus && zmapWindowFocusGetHotColumn(window->focus) == group) zmapWindowFocusReset(window->focus) ; } diff --git a/src/zmapWindow/zmapWindowFeature.c b/src/zmapWindow/zmapWindowFeature.c index 1bf411865..9bd98e629 100755 --- a/src/zmapWindow/zmapWindowFeature.c +++ b/src/zmapWindow/zmapWindowFeature.c @@ -30,7 +30,7 @@ * HISTORY: * Last edited: May 5 16:32 2010 (edgrif) * Created: Mon Jan 9 10:25:40 2006 (edgrif) - * CVS info: $Id: zmapWindowFeature.c,v 1.186 2010-06-08 08:31:26 mh17 Exp $ + * CVS info: $Id: zmapWindowFeature.c,v 1.187 2010-06-10 14:50:31 mh17 Exp $ *------------------------------------------------------------------- */ @@ -741,7 +741,8 @@ static gboolean canvasItemDestroyCB(FooCanvasItem *feature_item, gpointer data) /* Check to see if there is an entry in long items for this feature.... */ zmapWindowLongItemRemove(window->long_items, feature_item) ; /* Ignore boolean result. */ - zmapWindowFocusRemoveFocusItem(window->focus, feature_item); + if(window->focus) + zmapWindowFocusRemoveFocusItem(window->focus, feature_item); return event_handled ; } diff --git a/src/zmapWindow/zmapWindowFocus.c b/src/zmapWindow/zmapWindowFocus.c index 2203c2f19..939ddd297 100755 --- a/src/zmapWindow/zmapWindowFocus.c +++ b/src/zmapWindow/zmapWindowFocus.c @@ -6,12 +6,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -29,7 +29,7 @@ * HISTORY: * Last edited: Apr 30 11:00 2010 (edgrif) * Created: Tue Jan 16 09:46:23 2007 (rds) - * CVS info: $Id: zmapWindowFocus.c,v 1.18 2010-04-30 10:11:27 edgrif Exp $ + * CVS info: $Id: zmapWindowFocus.c,v 1.19 2010-06-10 14:50:32 mh17 Exp $ *------------------------------------------------------------------- */ @@ -39,10 +39,10 @@ #include <zmapWindowContainerFeatureSet_I.h> /* Used for window focus items and column. - * + * * Note that if only a column has been selected then focus_item_set may be NULL, BUT * if an item has been selected then focus_column will be that items parent. - * + * * */ typedef struct _ZMapWindowFocusStruct { @@ -66,7 +66,7 @@ typedef struct static gint find_item(gconstpointer list_data, gconstpointer user_data); -static ZMapWindowFocusItemArea ensure_unique(ZMapWindowFocus focus, +static ZMapWindowFocusItemArea ensure_unique(ZMapWindowFocus focus, FooCanvasItem *item); static void addFocusItemCB(gpointer data, gpointer user_data) ; static void freeFocusItems(ZMapWindowFocus focus) ; @@ -86,23 +86,23 @@ static void FocusUnmaskOverlay(ZMapWindowFocus focus); static gboolean overlay_manager_list_debug_G = FALSE; -/* +/* * Set of routines to handle focus items. - * + * * Holds a list of items that are highlighted/focussed, one of these is the "hot" item * which is the last one selected by the user. - * + * * The first item in the list is always the "hot" item. - * + * * The "add" functions just append item(s) to the list, they do not remove any items from it. - * + * * The "hot" item must be set with a separate call. - * + * * To replace the list you need to free it first then add new item(s). - * + * * Note that these routines do not handle highlighting of items, that must be done with * a separate call. - * + * */ @@ -260,10 +260,10 @@ FooCanvasGroup *zmapWindowFocusGetHotColumn(ZMapWindowFocus focus) return column ; } -/*! +/*! * zmapWindowFocusForEachFocusItem * - * Call given user function for all highlighted items. + * Call given user function for all highlighted items. * The data passed to the function will be a ZMapWindowFocusItemArea * * void callback(gpointer item_area_data, gpointer user_data); @@ -312,7 +312,7 @@ void zmapWindowFocusRemoveFocusItem(ZMapWindowFocus focus, FooCanvasItem *item) if ((curr_index = zmapWindowContainerGetItemPosition(ZMAP_CONTAINER_GROUP(container_parent), item)) != -1) { position = curr_index - focus->hot_item_orig_index ; - + if ((zmapWindowContainerSetItemPosition(ZMAP_CONTAINER_GROUP(container_parent), item, focus->hot_item_orig_index)) == -1) zMapLogWarning("%s", "zmapWindowContainerSetItemPosition() could not find item in container_parent.") ; @@ -370,7 +370,7 @@ void zmapWindowFocusRemoveOverlayManager(ZMapWindowFocus focus, ZMapWindowOverla { if(overlay_manager_list_debug_G) zMapLogWarning("removing overlay_manager %p from focus %p", overlay, focus); - + focus->overlay_managers = g_list_remove(focus->overlay_managers, overlay); return ; @@ -443,7 +443,7 @@ static ZMapWindowFocusItemArea ensure_unique(ZMapWindowFocus focus, FooCanvasIte if((remove = g_list_find_custom(focus->focus_item_set, item, find_item))) { item_area = remove->data; - focus->focus_item_set = g_list_remove(focus->focus_item_set, + focus->focus_item_set = g_list_remove(focus->focus_item_set, remove->data); associated = item_area->associated; item_area->associated = NULL; @@ -464,7 +464,7 @@ static gint find_item(gconstpointer list_data, gconstpointer user_data) { ZMapWindowFocusItemArea area = (ZMapWindowFocusItemArea)list_data; gint result = -1; - + if(user_data == (gconstpointer)(area->focus_item)) result = 0; @@ -474,7 +474,7 @@ static gint find_item(gconstpointer list_data, gconstpointer user_data) /* A GFunc() to add all items in a list to the windows focus item list. We don't want duplicates * so we try to remove an item first and then append it. This is a potential performance * problem if there is a _huge_ list of focus items.... - * + * NB: append requires processing the whole list * */ static void addFocusItemCB(gpointer data, gpointer user_data) { @@ -536,7 +536,7 @@ static FooCanvasItem *get_item_with_matching_frame(FooCanvasItem *any_item, FooCanvasGroup *container_parent, *container_features = NULL; ZMapWindowItemFeatureType item_feature_type; ContainerType container_type; - + /* possibly bad to have these 2 here, but wanted to not crash, but instead return NULL. */ item_feature_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(any_item), ITEM_FEATURE_TYPE)); container_type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(any_item), CONTAINER_TYPE_KEY)); @@ -645,7 +645,7 @@ static void setFocusColumn(ZMapWindowFocus focus, FooCanvasGroup *column) { focus->focus_column =container = (ZMapWindowContainerFeatureSet)column ; - + if (!container->sorted) { //zmapWindowContainerFeatureSetSortFeatures(focus->focus_column, ZMAPCONTAINER_VERTICAL) ; -- GitLab