1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +01:00

Avoid crash on icon move without command

This patch avoid a crash when moving an icon without command.
To reproduce the problem:

1. Launch an application, for example xeyes, with appicon.
2. Move the appicon to the clip.
3. Close the application.
4. Edit the appicon in the clip, and empty the commands fields.
5. Move the appicon from the clip to the dock. -> Crash.

The crash happends because icon->icon->owner is NULL and then
wwin will be NULL. Then the call of wwin->client_win will crash.

This patch checks if icon->icon->owner is not null (application is
running) and then assign it to wwin. Then get the command from the
running application.
This commit is contained in:
Rodolfo García Peñas (kix)
2012-11-22 22:40:12 +01:00
committed by Carlos R. Mafra
parent 914d4e06ef
commit bf2f942138

View File

@@ -1855,18 +1855,21 @@ Bool wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y, Bool update_icon
{
WWindow *wwin;
Bool lupdate_icon = False;
char *command = NULL;
int index;
wwin = icon->icon->owner;
icon->editing = 0;
if (update_icon)
lupdate_icon = True;
if (icon->command == NULL) {
char *command;
/* If icon->owner exists, it means the application is running */
if (icon->icon->owner) {
wwin = icon->icon->owner;
command = GetCommandForWindow(wwin->client_win);
}
command = GetCommandForWindow(wwin->client_win);
if (command) {
icon->command = command;
} else {
@@ -1986,7 +1989,7 @@ static void reattachIcon(WDock *dock, WAppIcon *icon, int x, int y)
static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x, int y)
{
WWindow *wwin;
char *command;
char *command = NULL;
int index;
Bool update_icon = False;
@@ -1996,8 +1999,6 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x,
if (dest == NULL)
return False;
wwin = icon->icon->owner;
/*
* For the moment we can't do this if we move icons in Clip from one
* workspace to other, because if we move two or more icons without
@@ -2005,7 +2006,12 @@ static Bool moveIconBetweenDocks(WDock *src, WDock *dest, WAppIcon *icon, int x,
* moved icons it applies. -Dan
*/
if ((dest->type == WM_DOCK /*|| dest->keep_attracted */ ) && icon->command == NULL) {
command = GetCommandForWindow(wwin->client_win);
/* If icon->owner exists, it means the application is running */
if (icon->icon->owner) {
wwin = icon->icon->owner;
command = GetCommandForWindow(wwin->client_win);
}
if (command) {
icon->command = command;
} else {