The Workspaces entry in the main menu allows to rename workspaces by
clicking on the workspace name while pressing the Ctrl key.
However since commit 63219247c6c7 ("Added shortcut to switch to last used
workspace")
there is one more entry before the workspace name list, and that leads to
picking a wrong name to rename -- clicking on the first workspace asks to
rename the second workspace and so forth. Trying to rename the last workspace
leads to a segfault.
This happens because there is an explicit offset in the current code (- 2)
to account for the "non-workspace" entries in the menu. If one adds one
more entry that offset should be changed too (this is a prime example
of fragile code leading to bugs).
Signed-off-by: Carlos R. Mafra <[email protected]>
---
src/menu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/menu.c b/src/menu.c
index 337b9e3..c250fa4 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1766,7 +1766,7 @@ static void menuMouseDown(WObjDescriptor * desc, XEvent *
event)
if (!close_on_exit && (bev->state & ControlMask) && smenu &&
entry->flags.editable) {
char buffer[128];
char *name;
- int number = entry_no - 2; /* Entries "New" and
"Destroy Last" appear before workspaces */
+ int number = entry_no - 3; /* Entries "New", "Destroy
Last" and "Last Used" appear before workspaces */
name = wstrdup(scr->workspaces[number]->name);
snprintf(buffer, sizeof(buffer), _("Type the name for
workspace %i:"), number + 1);
--
1.8.1.4
--
To unsubscribe, send mail to [email protected].