On Sat, 20 Apr 2013 at 14:05:00 +0200, Rodolfo García Peñas (kix) wrote:
> From: "Rodolfo García Peñas (kix)" <[email protected]>
> 
> This patch avoid update (create) the Workspace Menu when wmaker
> is starting. When wmaker is starting, the scr->current_workspace
> is NULL, so we can check it in wWorkspaceMenuUpdate() and do nothing.
> 
> --------------------------8<----------------------------------
> @@ -751,7 +751,12 @@ void wWorkspaceMenuUpdate(WScreen * scr, WMenu * menu)
>         WMenuEntry *entry;
>         int tmp;
> 
> -       if (!menu)
> +       /*
> +        * If the scr->current_workspace doesn't exists yet
> +        * is because we are starting wmaker, so we don't need
> +        * the workspace menu yet
> +        */
> +       if (!menu || !scr->current_workspace)
>                 return;
> --------------------------8<----------------------------------
> 
> So, now we don't need check in that function if the scr->current_workspace
> exists:
> 
> --------------------------8<----------------------------------
> -       if (scr->current_workspace) {
> -               menu->entries[scr->current_workspace + 
> MC_WORKSPACE1]->flags.indicator_on = 1;
> -               wMenuRealize(menu);
> -       }
> +       /* Update the workspace's menu */
> +       menu->entries[scr->current_workspace + 
> MC_WORKSPACE1]->flags.indicator_on = 1;
> +       wMenuRealize(menu);
> --------------------------8<----------------------------------

Wait! You just added this check in patch 1. This is a sign that your
patches are in wrong order.

Now your first patch should be

> +       if (!menu || !scr->current_workspace)

and then what was your first patch should be just the removal
of wWorkspace() -- possibly after another patch with the diff
below.

> 
> The problem is, in the function wWorkspaceRestoreState(), scr->workspace_menu
> could be "not NULL" and therefore it crash if the entries don't exits. So we
> need check it first. I used the variable "menu" to make the lines shorter and
> clear than "scr->workspace_menu":
> 
> --------------------------8<----------------------------------
> @@ -868,9 +872,13 @@ void wWorkspaceRestoreState(WScreen *scr)
>                         wWorkspaceNew(scr);
> 
>                 if (scr->workspace_menu) {
> -                       wfree(scr->workspace_menu->entries[i + 
> MC_WORKSPACE1]->text);
> -                       scr->workspace_menu->entries[i + MC_WORKSPACE1]->text 
> = wstrdup(WMGetFromPLString(pstr));
> -                       scr->workspace_menu->flags.realized = 0;
> +                       menu = scr->workspace_menu;
> +                       if (menu->entries[i + MC_WORKSPACE1] &&
> +                           menu->entries[i + MC_WORKSPACE1]->text) {
> +                               wfree(menu->entries[i + MC_WORKSPACE1]->text);
> +                               menu->entries[i + MC_WORKSPACE1]->text = 
> wstrdup(WMGetFromPLString(pstr));
> +                               menu->flags.realized = 0;
> +                       }

But I don't think you need to check menu->entries[]->text before
wfree'ing it if you already checked menu->entries[].


-- 
To unsubscribe, send mail to [email protected].

Reply via email to