libgnt/libgnt

Fix lifetimes of private GntWS contents.

2019-04-21, Elliott Sales de Andrade
184b3623c638
Parents acd19ce21b10
Children 608ca074312e
Fix lifetimes of private GntWS contents.

I don't know why GntWM is freeing name, but that's none of its concern.
Oddly, I don't think I see anything setting ->name or calling
gnt_ws_set_name.
  • +0 -8
    gntwm.c
  • +12 -1
    gntws.c
  • --- a/gntwm.c Fri Apr 19 23:38:43 2019 -0400
    +++ b/gntwm.c Sun Apr 21 00:24:52 2019 -0400
    @@ -1691,16 +1691,8 @@
    return NULL;
    }
    -static void
    -free_workspaces(gpointer data, G_GNUC_UNUSED gpointer n)
    -{
    - GntWS *s = data;
    - g_free(s->name);
    -}
    -
    void gnt_wm_set_workspaces(GntWM *wm, GList *workspaces)
    {
    - g_list_foreach(wm->workspaces, free_workspaces, NULL);
    wm->workspaces = workspaces;
    gnt_wm_switch_workspace(wm, 0);
    }
    --- a/gntws.c Fri Apr 19 23:38:43 2019 -0400
    +++ b/gntws.c Sun Apr 21 00:24:52 2019 -0400
    @@ -60,6 +60,14 @@
    * GObject Implementation
    *****************************************************************************/
    static void
    +gnt_ws_destroy(GObject *obj)
    +{
    + GntWS *ws = GNT_WS(obj);
    +
    + g_free(ws->name);
    +}
    +
    +static void
    gnt_ws_init(GntWS *ws)
    {
    ws->list = NULL;
    @@ -68,8 +76,11 @@
    }
    static void
    -gnt_ws_class_init(G_GNUC_UNUSED GntWSClass *klass)
    +gnt_ws_class_init(GntWSClass *klass)
    {
    + GObjectClass *obj_class = G_OBJECT_CLASS(klass);
    +
    + obj_class->dispose = gnt_ws_destroy;
    }
    /******************************************************************************