void vik_layer_emit_update ( VikLayer *vl )
{
if ( vl->visible && vl->realized ) {
+ GThread *thread = vik_window_get_thread ( VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(vl)) );
+ if ( !thread )
+ // Do nothing
+ return;
+
vik_window_set_redraw_trigger(vl);
// Only ever draw when there is time to do so
- if ( g_thread_self() != vik_window_get_thread (VIK_WINDOW(VIK_GTK_WINDOW_FROM_LAYER(vl))) )
+ if ( g_thread_self() != thread )
// Drawing requested from another (background) thread, so handle via the gdk thread method
gdk_threads_add_idle ( (GSourceFunc) idle_draw, vl );
else
void vik_layers_panel_emit_update ( VikLayersPanel *vlp )
{
+ GThread *thread = vik_window_get_thread (VIK_WINDOW(VIK_GTK_WINDOW_FROM_WIDGET(vlp)));
+ if ( !thread )
+ // Do nothing
+ return;
+
// Only ever draw when there is time to do so
- if ( g_thread_self() != vik_window_get_thread (VIK_WINDOW(VIK_GTK_WINDOW_FROM_WIDGET(vlp))) )
+ if ( g_thread_self() != thread )
// Drawing requested from another (background) thread, so handle via the gdk thread method
gdk_threads_add_idle ( (GSourceFunc) idle_draw_panel, vlp );
else
*/
void vik_window_statusbar_update ( VikWindow *vw, const gchar* message, vik_statusbar_type_t vs_type )
{
+ GThread *thread = vik_window_get_thread ( vw );
+ if ( !thread )
+ // Do nothing
+ return;
+
statusbar_idle_data *sid = g_malloc ( sizeof (statusbar_idle_data) );
sid->vs = vw->viking_vs;
sid->vs_type = vs_type;
sid->message = g_strdup ( message );
- if ( g_thread_self() == vik_window_get_thread ( vw ) ) {
+ if ( g_thread_self() == thread ) {
g_idle_add ( (GSourceFunc) statusbar_idle_update, sid );
}
else {
return need_redraw;
}
+/**
+ * May return NULL if the window no longer exists
+ */
GThread *vik_window_get_thread ( VikWindow *vw )
{
- return vw->thread;
+ if ( vw )
+ return vw->thread;
+ return NULL;
}