On Thu, Sep 16, 2010 at 3:31 PM, Bento Loewenstein <[email protected]> wrote:

> as soon as i get home i'll take another look. maybe pop a warning
> before dropping the entry.
>

here it is. now with warning popping goodness. plus, it makes the
default for a new "Run..." item
from example commands to be %A, to take advantage of completion.
---
 WPrefs.app/Menu.c |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c
index dccb85b..b495876 100644
--- a/WPrefs.app/Menu.c
+++ b/WPrefs.app/Menu.c
@@ -509,7 +509,7 @@ static void createPanel(_Panel * p)
                data->param.exec.command = "eterm";

                data = putNewItem(panel, pad, ExecInfo, _("Run..."));
-               data->param.exec.command = _("%a(Run,Type command to run)");
+               data->param.exec.command = _("%A(Run,Type command to run)");

                data = putNewItem(panel, pad, ExecInfo, _("Netscape"));
                data->param.exec.command = "netscape";
@@ -1029,8 +1029,12 @@ static ItemData *parseCommand(WMPropList * item)
                } else if (strcmp(command, "LEGAL_PANEL") == 0) {
                        cmd = 11;
                } else {
+
                        wwarning(_("unknown command '%s' in menu"), command);
-                       goto error;
+
+                       wfree(data);
+                       return NULL;
+
                }

                data->type = CommandInfo;
@@ -1043,11 +1047,6 @@ static ItemData *parseCommand(WMPropList * item)
        }

        return data;
-
- error:
-       wfree(data);
-
-       return NULL;
 }

 static void updateFrameTitle(_Panel * panel, char *title, InfoType type)
@@ -1400,9 +1399,17 @@ static WEditMenu *buildSubmenu(_Panel * panel,
WMPropList * pl)

                        data = parseCommand(pi);

-                       if (panel->markerPix[data->type])
-                               WSetEditMenuItemImage(item, 
panel->markerPix[data->type]);
-                       WSetEditMenuItemData(item, data, (WMCallback *) 
freeItemData);
+/* This is where invalid entries are dealt with. this prevents a
segfault       *
+ * It'll leave the menu entry after the pop-up is dismissed, but
it'll be empty *
+ * Not sure if this is the best way, or maybe just remove the entry
altogheter  *
+ */
+                       if (data != NULL) {
+                               if (panel->markerPix[data->type])
+                                       WSetEditMenuItemImage(item, 
panel->markerPix[data->type]);
+                               WSetEditMenuItemData(item, data, (WMCallback *) 
freeItemData);
+                       } else {
+                               WMRunAlertPanel(scr, panel->parent,
+                                               _("Warning"),
+                                               _("An invalid menu item was 
found.\n"
+                                               "The item was cleared to avoid 
undesired effects."),
+                                               _("OK"), NULL, NULL);
+                       }
                }
        }

-- 
1.7.0.4


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

Reply via email to