Fix crash in taskbar after visible task changed name then gone.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 11 Oct 2014 23:53:43 +0000 (02:53 +0300)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Sat, 11 Oct 2014 23:53:43 +0000 (02:53 +0300)
The name of task in class is kept as a pointer to name of task but when
it changed name, the pointer was never reset so becomes invalid -> crash.
The commit resets pointer if task was gone from class or was renamed.

ChangeLog
plugins/launchtaskbar.c

index db11818..f785f64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
     server uses unsigned long which is 64 bit on 64-bit architectures.
 * Adapted to use libmenu-cache >= 1.0.0 - it could show empty folders in
     the desktop menu.
+* Fixed crash in taskbar after visible task changed name then gone.
 
 0.7.1
 -------------------------------------------------------------------------
index d043933..fb0dd2a 100644 (file)
@@ -1658,6 +1658,12 @@ static gboolean accept_net_wm_window_type(NetWMWindowType * nwwt)
 /* Free the names associated with a task. */
 static void task_free_names(Task * tk)
 {
+    TaskClass * tc = tk->p_taskclass;
+
+    if (tc != NULL && tk->name != NULL)
+        /* Reset the name from class */
+        if (tc->visible_name == tk->name)
+            tc->visible_name = tc->res_class;
     g_free(tk->name);
     g_free(tk->name_iconified);
     tk->name = tk->name_iconified = NULL;
@@ -1716,6 +1722,10 @@ static void task_unlink_class(Task * tk)
     TaskClass * tc = tk->p_taskclass;
     if (tc != NULL)
     {
+        /* Reset the name from class */
+        if (tc->visible_name == tk->name)
+            tc->visible_name = tc->res_class;
+
         /* Action in Launchbar after class removed */
         launchbar_update_after_taskbar_class_removed(tk->tb, tk);
 
@@ -1740,6 +1750,7 @@ static void task_unlink_class(Task * tk)
                 tk_pred->p_task_flink_same_class = tk->p_task_flink_same_class;
         }
         tk->p_task_flink_same_class = NULL;
+        tk->p_taskclass = NULL;
 
         /* Recompute group visibility. */
         recompute_group_visibility_for_class(tk->tb, tc);