From f01eebd4992e8e28a74b9943b7a3597e4e3a95eb Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Thu, 24 Nov 2011 23:09:24 +0000 Subject: [PATCH] Fix: Improve internal redrawing method. Should now have no race conditions / lock outs to be more reliable when handling (e.g. downloading) multiple sources and redrawing the screen at any time by using the appropriate gtk idle drawing methods for all updates. --- src/vikdemlayer.c | 15 +++---- src/vikgeoreflayer.c | 4 +- src/vikgpslayer.c | 8 +--- src/viklayer.c | 33 +++++++++++++--- src/viklayer.h | 2 +- src/viklayerspanel.c | 2 +- src/vikmapslayer.c | 4 +- src/viktrwlayer.c | 82 +++++++++++++++++++-------------------- src/viktrwlayer_propwin.c | 10 ++--- 9 files changed, 86 insertions(+), 74 deletions(-) diff --git a/src/vikdemlayer.c b/src/vikdemlayer.c index aac7f71f..b2fc0557 100644 --- a/src/vikdemlayer.c +++ b/src/vikdemlayer.c @@ -320,11 +320,11 @@ static int dem_layer_load_list_thread ( dem_load_thread_data *dltd, gpointer thr // ATM as each file is processed the screen is not updated (no mechanism exposed to a_dems_load_list) // Thus force draw only at the end, as loading is complete/aborted - gdk_threads_enter(); + //gdk_threads_enter(); // Test is helpful to prevent Gtk-CRITICAL warnings if the program is exitted whilst loading if ( IS_VIK_LAYER(dltd->vdl) ) - vik_layer_emit_update ( VIK_LAYER(dltd->vdl) ); - gdk_threads_leave(); + vik_layer_emit_update ( VIK_LAYER(dltd->vdl), TRUE ); // Yes update from background thread + //gdk_threads_leave(); return result; } @@ -1068,7 +1068,6 @@ static gboolean dem_layer_add_file ( VikDEMLayer *vdl, const gchar *full_path ) vdl->files = g_list_prepend ( vdl->files, duped_path ); a_dems_load ( duped_path ); g_debug("%s: %s", __FUNCTION__, duped_path); - vik_layer_emit_update ( VIK_LAYER(vdl) ); } return TRUE; } else @@ -1086,16 +1085,16 @@ static void dem_download_thread ( DEMDownloadParams *p, gpointer threaddata ) else return; - gdk_threads_enter(); + //gdk_threads_enter(); g_mutex_lock ( p->mutex ); if ( p->vdl ) { g_object_weak_unref ( G_OBJECT(p->vdl), weak_ref_cb, p ); if ( dem_layer_add_file ( p->vdl, p->dest ) ) - vik_layer_emit_update ( VIK_LAYER(p->vdl) ); + vik_layer_emit_update ( VIK_LAYER(p->vdl), TRUE ); // Yes update from background thread } g_mutex_unlock ( p->mutex ); - gdk_threads_leave(); + //gdk_threads_leave(); } @@ -1157,6 +1156,8 @@ static gboolean dem_layer_download_release ( VikDEMLayer *vdl, GdkEventButton *e g_free ( tmp ); } + else + vik_layer_emit_update ( VIK_LAYER(vdl), FALSE ); g_free ( dem_file ); g_free ( full_path ); diff --git a/src/vikgeoreflayer.c b/src/vikgeoreflayer.c index a00be811..c71229b8 100644 --- a/src/vikgeoreflayer.c +++ b/src/vikgeoreflayer.c @@ -630,7 +630,7 @@ static gboolean georef_layer_move_release ( VikGeorefLayer *vgl, GdkEventButton { vgl->corner.easting += (event->x - vgl->click_x) * vik_viewport_get_xmpp (vvp); vgl->corner.northing -= (event->y - vgl->click_y) * vik_viewport_get_ympp (vvp); - vik_layer_emit_update ( VIK_LAYER(vgl) ); + vik_layer_emit_update ( VIK_LAYER(vgl), FALSE ); return TRUE; } return FALSE; /* I didn't move anything on this layer! */ @@ -663,7 +663,7 @@ static gboolean georef_layer_zoom_press ( VikGeorefLayer *vgl, GdkEventButton *e } vik_viewport_set_xmpp ( vvp, vgl->mpp_easting ); vik_viewport_set_ympp ( vvp, vgl->mpp_northing ); - vik_layer_emit_update ( VIK_LAYER(vgl) ); + vik_layer_emit_update ( VIK_LAYER(vgl), FALSE ); return TRUE; } diff --git a/src/vikgpslayer.c b/src/vikgpslayer.c index 2cb467ec..9d40b838 100644 --- a/src/vikgpslayer.c +++ b/src/vikgpslayer.c @@ -1074,7 +1074,6 @@ static void gps_comm_thread(GpsSession *sess) result = a_babel_convert_to (sess->vtl, sess->cmd_args, (BabelStatusFunc) gps_upload_progress_func, sess->port, sess); - gdk_threads_enter(); if (!result) { gtk_label_set_text ( GTK_LABEL(sess->status_label), _("Error: couldn't find gpsbabel.") ); } @@ -1093,7 +1092,7 @@ static void gps_comm_thread(GpsSession *sess) if (sess->vvp) { /* View the data available */ vik_trw_layer_auto_set_view ( sess->vtl, sess->vvp) ; - vik_layer_emit_update ( VIK_LAYER(sess->vtl) ); + vik_layer_emit_update ( VIK_LAYER(sess->vtl), TRUE ); // Yes update from background thread } } } else { @@ -1111,7 +1110,6 @@ static void gps_comm_thread(GpsSession *sess) g_mutex_unlock(sess->mutex); gps_session_delete(sess); } - gdk_threads_leave(); g_thread_exit(NULL); } @@ -1452,9 +1450,7 @@ static void gpsd_raw_hook(VglGpsd *vgpsd, gchar *data) vgl->first_realtime_trackpoint = FALSE; create_realtime_trackpoint(vgl, FALSE); - gdk_threads_enter(); - vik_layer_emit_update ( update_all ? VIK_LAYER(vgl) : VIK_LAYER(vgl->trw_children[TRW_REALTIME])); - gdk_threads_leave(); + vik_layer_emit_update ( update_all ? VIK_LAYER(vgl) : VIK_LAYER(vgl->trw_children[TRW_REALTIME]), TRUE); // Yes update from background thread } } diff --git a/src/viklayer.c b/src/viklayer.c index c111764c..926b9390 100644 --- a/src/viklayer.c +++ b/src/viklayer.c @@ -95,28 +95,49 @@ static void layer_class_init (VikLayerClass *klass) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); } -void vik_layer_emit_update ( VikLayer *vl ) +/** + * Invoke the actual drawing via signal method + */ +static gboolean idle_draw ( VikLayer *vl ) +{ + g_signal_emit ( G_OBJECT(vl), layer_signals[VL_UPDATE_SIGNAL], 0 ); + return FALSE; // Nothing else to do +} + +/** + * Draw specified layer + */ +void vik_layer_emit_update ( VikLayer *vl, gboolean from_background ) { if ( vl->visible ) { vik_window_set_redraw_trigger(vl); - g_signal_emit ( G_OBJECT(vl), layer_signals[VL_UPDATE_SIGNAL], 0 ); + + // Only ever draw when there is time to do so + if ( from_background ) + // Drawing requested from background thread, so handle via the gdk thread method + gdk_threads_add_idle ( (GSourceFunc) idle_draw, vl ); + else + g_idle_add ( (GSourceFunc) idle_draw, vl ); } } -/* should only be done by VikLayersPanel -- need to redraw and record trigger - * when we make a layer invisible. +/** + * should only be done by VikLayersPanel (hence never used from the background) + * need to redraw and record trigger when we make a layer invisible. */ void vik_layer_emit_update_although_invisible ( VikLayer *vl ) { vik_window_set_redraw_trigger(vl); - g_signal_emit ( G_OBJECT(vl), layer_signals[VL_UPDATE_SIGNAL], 0 ); + g_idle_add ( (GSourceFunc) idle_draw, vl ); } /* doesn't set the trigger. should be done by aggregate layer when child emits update. */ void vik_layer_emit_update_secondary ( VikLayer *vl ) { if ( vl->visible ) - g_signal_emit ( G_OBJECT(vl), layer_signals[VL_UPDATE_SIGNAL], 0 ); + // TODO: this can used from the background - eg in acquire + // so will need to flow background update status through too + g_idle_add ( (GSourceFunc) idle_draw, vl ); } static VikLayerInterface *vik_layer_interfaces[VIK_LAYER_NUM_TYPES] = { diff --git a/src/viklayer.h b/src/viklayer.h index 4400d64f..36c6d375 100644 --- a/src/viklayer.h +++ b/src/viklayer.h @@ -273,7 +273,7 @@ const gchar *vik_layer_get_name ( VikLayer *l ); gboolean vik_layer_set_param (VikLayer *layer, guint16 id, VikLayerParamData data, gpointer vp, gboolean is_file_operation); -void vik_layer_emit_update ( VikLayer *vl ); +void vik_layer_emit_update ( VikLayer *vl, gboolean from_background ); /* GUI */ void vik_layer_set_menu_items_selection(VikLayer *l, guint16 selection); diff --git a/src/viklayerspanel.c b/src/viklayerspanel.c index aa89e9eb..3e56a6ed 100644 --- a/src/viklayerspanel.c +++ b/src/viklayerspanel.c @@ -521,7 +521,7 @@ gboolean vik_layers_panel_properties ( VikLayersPanel *vlp ) a_dialog_info_msg ( VIK_GTK_WINDOW_FROM_WIDGET(vlp), _("Aggregate Layers have no settable properties.") ); VikLayer *layer = VIK_LAYER( vik_treeview_item_get_pointer ( vlp->vt, &iter ) ); if (vik_layer_properties ( layer, vlp->vvp )) - vik_layer_emit_update ( layer ); + vik_layer_emit_update ( layer, FALSE ); return TRUE; } else diff --git a/src/vikmapslayer.c b/src/vikmapslayer.c index ad091ffe..660463c6 100644 --- a/src/vikmapslayer.c +++ b/src/vikmapslayer.c @@ -1010,16 +1010,14 @@ static int map_download_thread ( MapDownloadInfo *mdi, gpointer threaddata ) continue; } - gdk_threads_enter(); g_mutex_lock(mdi->mutex); if (remove_mem_cache) a_mapcache_remove_all_shrinkfactors ( x, y, mdi->mapcoord.z, vik_map_source_get_uniq_id(MAPS_LAYER_NTH_TYPE(mdi->maptype)), mdi->mapcoord.scale ); if (mdi->refresh_display && mdi->map_layer_alive) { /* TODO: check if it's on visible area */ - vik_layer_emit_update ( VIK_LAYER(mdi->vml) ); + vik_layer_emit_update ( VIK_LAYER(mdi->vml), TRUE ); // Yes update display from background } g_mutex_unlock(mdi->mutex); - gdk_threads_leave(); mdi->mapcoord.x = mdi->mapcoord.y = 0; /* we're temporarily between downloads */ } diff --git a/src/viktrwlayer.c b/src/viktrwlayer.c index 74004c0b..4a91a0df 100644 --- a/src/viktrwlayer.c +++ b/src/viktrwlayer.c @@ -633,7 +633,7 @@ static gboolean trw_layer_paste_item ( VikTrwLayer *vtl, gint subtype, guint8 *i waypoint_convert(name, w, &vtl->coord_mode); // Consider if redraw necessary for the new item if ( vtl->vl.visible && vtl->waypoints_visible && w->visible ) - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } if ( subtype == VIK_TRW_LAYER_SUBLAYER_TRACK && fi ) @@ -646,7 +646,7 @@ static gboolean trw_layer_paste_item ( VikTrwLayer *vtl, gint subtype, guint8 *i track_convert(name, t, &vtl->coord_mode); // Consider if redraw necessary for the new item if ( vtl->vl.visible && vtl->tracks_visible && t->visible ) - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } return FALSE; @@ -2875,8 +2875,7 @@ void vik_trw_layer_delete_all_tracks ( VikTrwLayer *vtl ) g_hash_table_remove_all(vtl->tracks_iters); g_hash_table_remove_all(vtl->tracks); - /* TODO: only update if the layer is visible (ticked) */ - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); } void vik_trw_layer_delete_all_waypoints ( VikTrwLayer *vtl ) @@ -2891,8 +2890,7 @@ void vik_trw_layer_delete_all_waypoints ( VikTrwLayer *vtl ) g_hash_table_remove_all(vtl->waypoints_iters); g_hash_table_remove_all(vtl->waypoints); - /* TODO: only update if the layer is visible (ticked) */ - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); } static void trw_layer_delete_all_tracks ( gpointer lav[2] ) @@ -2941,7 +2939,7 @@ static void trw_layer_delete_item ( gpointer pass_along[6] ) was_visible = vik_trw_layer_delete_track ( vtl, (gchar *) pass_along[3] ); } if ( was_visible ) - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); } @@ -2957,7 +2955,7 @@ static void trw_layer_properties_item ( gpointer pass_along[6] ) a_dialog_waypoint ( VIK_GTK_WINDOW_FROM_LAYER(vtl), pass_along[3], wp, NULL, vtl->coord_mode, FALSE, &updated ); if ( updated && VIK_LAYER(vtl)->visible ) - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); } } else @@ -2989,7 +2987,7 @@ static void goto_coord ( gpointer *vlp, gpointer vl, gpointer vvp, const VikCoor /* since vlp not set, vl & vvp should be valid instead! */ if ( vl && vvp ) { vik_viewport_set_center_coord ( VIK_VIEWPORT(vvp), coord ); - vik_layer_emit_update ( VIK_LAYER(vl) ); + vik_layer_emit_update ( VIK_LAYER(vl), FALSE ); } } } @@ -3104,7 +3102,7 @@ static void trw_layer_auto_track_view ( gpointer pass_along[5] ) if ( pass_along[1] ) vik_layers_panel_emit_update ( VIK_LAYERS_PANEL(pass_along[1]) ); else - vik_layer_emit_update ( VIK_LAYER(pass_along[0]) ); + vik_layer_emit_update ( VIK_LAYER(pass_along[0]), FALSE ); } } @@ -3305,7 +3303,7 @@ static void trw_layer_merge_with_other ( gpointer pass_along[6] ) for (l = merge_list; l != NULL; l = g_list_next(l)) g_free(l->data); g_list_free(merge_list); - vik_layer_emit_update( VIK_LAYER(vtl) ); + vik_layer_emit_update( VIK_LAYER(vtl), FALSE ); } } @@ -3419,7 +3417,7 @@ static void trw_layer_merge_by_timestamp ( gpointer pass_along[6] ) } while (track_count > 1); g_list_free(nearby_tracks); free(orig_track_name); - vik_layer_emit_update( VIK_LAYER(vtl) ); + vik_layer_emit_update( VIK_LAYER(vtl), FALSE ); } /* split by time routine */ @@ -3491,7 +3489,7 @@ static void trw_layer_split_by_timestamp ( gpointer pass_along[6] ) iter = g_list_next(iter); } vik_trw_layer_delete_track(VIK_TRW_LAYER(pass_along[0]), (gchar *)pass_along[3]); - vik_layer_emit_update(VIK_LAYER(pass_along[0])); + vik_layer_emit_update(VIK_LAYER(pass_along[0]), FALSE); } g_list_free(newlists); } @@ -3566,7 +3564,7 @@ static void trw_layer_split_by_n_points ( gpointer pass_along[6] ) } // Remove original track and then update the display vik_trw_layer_delete_track(VIK_TRW_LAYER(pass_along[0]), (gchar *)pass_along[3]); - vik_layer_emit_update(VIK_LAYER(pass_along[0])); + vik_layer_emit_update(VIK_LAYER(pass_along[0]), FALSE); } g_list_free(newlists); } @@ -3615,7 +3613,7 @@ static void trw_layer_delete_tracks_from_selection ( gpointer lav[2] ) vik_trw_layer_delete_track(vtl, l->data); } g_list_free(delete_list); - vik_layer_emit_update( VIK_LAYER(vtl) ); + vik_layer_emit_update( VIK_LAYER(vtl), FALSE ); } } @@ -3652,7 +3650,7 @@ static void trw_layer_delete_waypoints_from_selection ( gpointer lav[2] ) vik_trw_layer_delete_waypoint(vtl, l->data); } g_list_free(delete_list); - vik_layer_emit_update( VIK_LAYER(vtl) ); + vik_layer_emit_update( VIK_LAYER(vtl), FALSE ); } } @@ -4201,7 +4199,7 @@ static void trw_layer_cancel_current_tp ( VikTrwLayer *vtl, gboolean destroy ) { vtl->current_tpl = NULL; vtl->current_tp_track_name = NULL; - vik_layer_emit_update(VIK_LAYER(vtl)); + vik_layer_emit_update(VIK_LAYER(vtl), FALSE); } } @@ -4237,7 +4235,7 @@ static void trw_layer_tpwin_response ( VikTrwLayer *vtl, gint response ) tr->visible = TRUE; vik_trw_layer_add_track ( vtl, name, tr ); - vik_layer_emit_update(VIK_LAYER(vtl)); + vik_layer_emit_update(VIK_LAYER(vtl), FALSE); } } else if ( response == VIK_TRW_LAYER_TPWIN_DELETE ) @@ -4265,7 +4263,7 @@ static void trw_layer_tpwin_response ( VikTrwLayer *vtl, gint response ) g_free ( vtl->current_tpl->data ); /* TODO: vik_trackpoint_free() */ g_list_free_1 ( vtl->current_tpl ); vtl->current_tpl = new_tpl; - vik_layer_emit_update(VIK_LAYER(vtl)); + vik_layer_emit_update(VIK_LAYER(vtl), FALSE); } else { @@ -4279,13 +4277,13 @@ static void trw_layer_tpwin_response ( VikTrwLayer *vtl, gint response ) { vtl->last_tpl = vtl->current_tpl; vik_trw_layer_tpwin_set_tp ( vtl->tpwin, vtl->current_tpl = vtl->current_tpl->next, vtl->current_tp_track_name ); - vik_layer_emit_update(VIK_LAYER(vtl)); /* TODO longone: either move or only update if tp is inside drawing window */ + vik_layer_emit_update(VIK_LAYER(vtl), FALSE); /* TODO longone: either move or only update if tp is inside drawing window */ } else if ( response == VIK_TRW_LAYER_TPWIN_BACK && vtl->current_tpl->prev ) { vtl->last_tpl = vtl->current_tpl; vik_trw_layer_tpwin_set_tp ( vtl->tpwin, vtl->current_tpl = vtl->current_tpl->prev, vtl->current_tp_track_name ); - vik_layer_emit_update(VIK_LAYER(vtl)); + vik_layer_emit_update(VIK_LAYER(vtl), FALSE); } else if ( response == VIK_TRW_LAYER_TPWIN_JOIN ) { @@ -4326,15 +4324,15 @@ static void trw_layer_tpwin_response ( VikTrwLayer *vtl, gint response ) vik_trw_layer_delete_track ( vtl, tmp ); trw_layer_cancel_last_tp ( vtl ); /* same TP, can't join. */ - vik_layer_emit_update(VIK_LAYER(vtl)); + vik_layer_emit_update(VIK_LAYER(vtl), FALSE); } else if ( response == VIK_TRW_LAYER_TPWIN_INSERT && vtl->current_tpl->next ) { trw_layer_insert_tp_after_current_tp ( vtl ); - vik_layer_emit_update(VIK_LAYER(vtl)); + vik_layer_emit_update(VIK_LAYER(vtl), FALSE); } else if ( response == VIK_TRW_LAYER_TPWIN_DATA_CHANGED ) - vik_layer_emit_update (VIK_LAYER(vtl)); + vik_layer_emit_update(VIK_LAYER(vtl), FALSE); } static void trw_layer_tpwin_init ( VikTrwLayer *vtl ) @@ -4550,7 +4548,7 @@ static gboolean trw_layer_select_release ( VikTrwLayer *vtl, GdkEventButton *eve vtl->current_wp_name = NULL; trw_layer_cancel_current_tp ( vtl, FALSE ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } return FALSE; @@ -4604,7 +4602,7 @@ static gboolean trw_layer_select_click ( VikTrwLayer *vtl, GdkEventButton *event vtl->current_wp = wp_params.closest_wp; vtl->current_wp_name = wp_params.closest_wp_name; - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } @@ -4645,7 +4643,7 @@ static gboolean trw_layer_select_click ( VikTrwLayer *vtl, GdkEventButton *event if ( vtl->tpwin ) vik_trw_layer_tpwin_set_tp ( vtl->tpwin, vtl->current_tpl, vtl->current_tp_track_name ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } } @@ -4840,14 +4838,14 @@ static gboolean tool_edit_waypoint_click ( VikTrwLayer *vtl, GdkEventButton *eve vtl->current_wp_name = params.closest_wp_name; /* could make it so don't update if old WP is off screen and new is null but oh well */ - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } vtl->current_wp = NULL; vtl->current_wp_name = NULL; vtl->waypoint_rightclick = FALSE; - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return FALSE; } @@ -4922,7 +4920,7 @@ static gboolean tool_edit_waypoint_release ( VikTrwLayer *vtl, GdkEventButton *e marker_end_move ( t ); vtl->current_wp->coord = new_coord; - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } /* PUT IN RIGHT PLACE!!! */ @@ -5133,7 +5131,7 @@ static gboolean tool_new_track_key_press ( VikTrwLayer *vtl, GdkEventKey *event, { if ( vtl->current_track && event->keyval == GDK_Escape ) { vtl->current_track = NULL; - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } else if ( vtl->current_track && event->keyval == GDK_BackSpace ) { /* undo */ @@ -5146,7 +5144,7 @@ static gboolean tool_new_track_key_press ( VikTrwLayer *vtl, GdkEventKey *event, update_statusbar ( vtl ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } return FALSE; @@ -5170,7 +5168,7 @@ static gboolean tool_new_track_click ( VikTrwLayer *vtl, GdkEventButton *event, } update_statusbar ( vtl ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } @@ -5185,7 +5183,7 @@ static gboolean tool_new_track_click ( VikTrwLayer *vtl, GdkEventButton *event, /* undo last, then end */ vtl->current_track = NULL; } - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } @@ -5227,7 +5225,7 @@ static gboolean tool_new_track_click ( VikTrwLayer *vtl, GdkEventButton *event, vtl->ct_x2 = event->x; vtl->ct_y2 = event->y; - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } @@ -5245,7 +5243,7 @@ static gboolean tool_new_waypoint_click ( VikTrwLayer *vtl, GdkEventButton *even return FALSE; vik_viewport_screen_to_coord ( vvp, event->x, event->y, &coord ); if (vik_trw_layer_new_waypoint ( vtl, VIK_GTK_WINDOW_FROM_LAYER(vtl), &coord ) && VIK_LAYER(vtl)->visible) - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } @@ -5317,7 +5315,7 @@ static gboolean tool_edit_trackpoint_click ( VikTrwLayer *vtl, GdkEventButton *e vtl->current_tp_track_name = params.closest_track_name; trw_layer_tpwin_init ( vtl ); set_statusbar_msg_info_trkpt ( vtl, params.closest_tp ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } @@ -5389,7 +5387,7 @@ static gboolean tool_edit_trackpoint_release ( VikTrwLayer *vtl, GdkEventButton /* can't join with itself! */ trw_layer_cancel_last_tp ( vtl ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); return TRUE; } return FALSE; @@ -5413,7 +5411,7 @@ static gboolean tool_route_finder_click ( VikTrwLayer *vtl, GdkEventButton *even if ( new_end ) { vtl->route_finder_coord = *new_end; g_free ( new_end ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); /* remove last ' to:...' */ if ( vtl->route_finder_current_track->comment ) { gchar *last_to = strrchr ( vtl->route_finder_current_track->comment, 't' ); @@ -5472,7 +5470,7 @@ static gboolean tool_route_finder_click ( VikTrwLayer *vtl, GdkEventButton *even vtl->route_finder_check_added_track = FALSE; vtl->route_finder_append = FALSE; - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); } else { vtl->route_finder_started = TRUE; vtl->route_finder_coord = tmp; @@ -5580,10 +5578,8 @@ static int create_thumbnails_thread ( thumbnail_create_thread_data *tctd, gpoint } // Redraw to show the thumbnails as they are now created - gdk_threads_enter(); if ( IS_VIK_LAYER(tctd->vtl) ) - vik_layer_emit_update ( VIK_LAYER(tctd->vtl) ); - gdk_threads_leave(); + vik_layer_emit_update ( VIK_LAYER(tctd->vtl), TRUE ); // Yes update from background thread return 0; } diff --git a/src/viktrwlayer_propwin.c b/src/viktrwlayer_propwin.c index a4edcc11..89a013df 100644 --- a/src/viktrwlayer_propwin.c +++ b/src/viktrwlayer_propwin.c @@ -311,7 +311,7 @@ static VikTrackpoint *set_center_at_graph_position(gdouble event_x, /* since vlp not set, vvp should be valid instead! */ if ( vvp ) vik_viewport_set_center_coord ( vvp, &coord ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); } } return trackpoint; @@ -2303,13 +2303,13 @@ static void propwin_response_cb( GtkDialog *dialog, gint resp, PropWidgets *widg break; case VIK_TRW_LAYER_PROPWIN_REVERSE: vik_track_reverse(tr); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); break; case VIK_TRW_LAYER_PROPWIN_DEL_DUP: vik_track_remove_dup_points(tr); /* above operation could have deleted current_tp or last_tp */ trw_layer_cancel_tps_of_track ( vtl, widgets->track_name ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); break; case VIK_TRW_LAYER_PROPWIN_SPLIT: { @@ -2346,7 +2346,7 @@ static void propwin_response_cb( GtkDialog *dialog, gint resp, PropWidgets *widg /* Don't let track destroy this dialog */ vik_track_clear_property_dialog(tr); vik_trw_layer_delete_track ( vtl, widgets->track_name ); - vik_layer_emit_update ( VIK_LAYER(vtl) ); /* chase thru the hoops */ + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); /* chase thru the hoops */ } } break; @@ -2390,7 +2390,7 @@ static void propwin_response_cb( GtkDialog *dialog, gint resp, PropWidgets *widg tr_right->trackpoints = iter; vik_trw_layer_add_track(vtl, r_name, tr_right); - vik_layer_emit_update ( VIK_LAYER(vtl) ); + vik_layer_emit_update ( VIK_LAYER(vtl), FALSE ); } break; default: -- 2.39.5