diff --git a/ChangeLog b/ChangeLog index 4b2f51e396..cfc48133ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 13 John (J5) Palmieri + + * info-daemon/NetworkManagerInfo.c (nmi_spawn_notification_icon): Stop respawning + if the notification icon crashes 5 times within 5 seconds of each respawn + Tue Oct 12 22:53:04 2004 Jonathan Blandford * panel-applet/NMWirelessApplet.c (nmwa_update_state): remove diff --git a/info-daemon/NetworkManagerInfo.c b/info-daemon/NetworkManagerInfo.c index d8e76ad3e0..410139153b 100644 --- a/info-daemon/NetworkManagerInfo.c +++ b/info-daemon/NetworkManagerInfo.c @@ -109,19 +109,45 @@ nmi_spawn_notification_icon (NMIAppInfo *info) if (info->notification_icon_watch != NULL) g_source_remove (info->notification_icon_watch); - /*spawn the panel notification icon*/ - if (!g_spawn_async (NULL, - notification_icon_cmd, - NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, - &(info->notification_icon_pid), - &error)) - { - g_warning ("Could not spawn NetworkManager's notification icon (%s)", error->message); - g_error_free (error); - } + if (info->notification_icon_respawn_timer == NULL) + info->notification_icon_respawn_timer = g_timer_new(); else - info->notification_icon_watch = g_child_watch_add (info->notification_icon_pid, on_icon_exit_callback, info); + { + gdouble elapsed_time; + gulong dummy; + elapsed_time = g_timer_elapsed (info->notification_icon_respawn_timer, &dummy); + + /*5 seconds between respawns*/ + if (elapsed_time > 5) + info->notification_icon_respawn_counter = 0; + else + info->notification_icon_respawn_counter++; + + } + + g_timer_start (info->notification_icon_respawn_timer); + + /*spawn the panel notification icon unless it has crashed numerous times within a time frame*/ + if (info->notification_icon_respawn_counter < 5) + { + if (!g_spawn_async (NULL, + notification_icon_cmd, + NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, + &(info->notification_icon_pid), + &error)) + { + g_warning ("Could not spawn NetworkManager's notification icon (%s)", error->message); + g_error_free (error); + } + else + { + info->notification_icon_watch = g_child_watch_add (info->notification_icon_pid, on_icon_exit_callback, info); + } + } else { + g_timer_destroy (info->notification_icon_respawn_timer); + info->notification_icon_respawn_timer = NULL; + } } #endif diff --git a/info-daemon/NetworkManagerInfo.h b/info-daemon/NetworkManagerInfo.h index 14fcc4935e..be44bf5c84 100644 --- a/info-daemon/NetworkManagerInfo.h +++ b/info-daemon/NetworkManagerInfo.h @@ -49,6 +49,8 @@ struct NMIAppInfo */ GPid notification_icon_pid; guint notification_icon_watch; + guint notification_icon_respawn_counter; + GTimer *notification_icon_respawn_timer; GSource *shutdown_timeout; };