Skip to content

Commit 09d31d4

Browse files
committed
WM/window.c(wWindowDestroy): added extra checks before resource releasing. Could fix provlems described in issue #491.
1 parent 2de917c commit 09d31d4

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

Applications/Workspace/WM/window.c

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,13 @@ void wWindowDestroy(WWindow *wwin)
175175
int i, win_count;
176176
CFIndex idx;
177177

178-
if (wwin->screen->cmap_window == wwin)
178+
if (!wwin || !wwin->screen) {
179+
return;
180+
}
181+
182+
if (wwin->screen->cmap_window && wwin->screen->cmap_window == wwin) {
179183
wwin->screen->cmap_window = NULL;
184+
}
180185

181186
if (wwin->screen->notificationCenter) {
182187
CFNotificationCenterRemoveObserver(wwin->screen->notificationCenter, wwin,
@@ -211,38 +216,39 @@ void wWindowDestroy(WWindow *wwin)
211216
XFlush(dpy);
212217
}
213218
}
214-
215-
if (wwin->normal_hints)
219+
if (wwin->normal_hints) {
216220
XFree(wwin->normal_hints);
217-
218-
if (wwin->wm_hints)
221+
}
222+
if (wwin->wm_hints) {
219223
XFree(wwin->wm_hints);
220-
221-
if (wwin->wm_instance)
224+
}
225+
if (wwin->wm_instance) {
222226
XFree(wwin->wm_instance);
223-
224-
if (wwin->wm_class)
227+
}
228+
if (wwin->wm_class) {
225229
XFree(wwin->wm_class);
226-
227-
if (wwin->wm_gnustep_attr)
230+
}
231+
if (wwin->wm_gnustep_attr) {
228232
wfree(wwin->wm_gnustep_attr);
229-
230-
if (wwin->cmap_windows)
233+
}
234+
if (wwin->cmap_windows) {
231235
XFree(wwin->cmap_windows);
232-
233-
XDeleteContext(dpy, wwin->client_win, w_global.context.client_win);
234-
235-
if (wwin->frame)
236+
}
237+
if (wwin->client_win) {
238+
XDeleteContext(dpy, wwin->client_win, w_global.context.client_win);
239+
}
240+
if (wwin->frame) {
236241
wFrameWindowDestroy(wwin->frame);
237-
242+
}
238243
if (wwin->icon) {
239244
RemoveFromStackList(wwin->icon->core);
240245
wIconDestroy(wwin->icon);
241246
if (wPreferences.auto_arrange_icons)
242247
wArrangeIcons(wwin->screen, True);
243248
}
244-
if (wwin->net_icon_image)
249+
if (wwin->net_icon_image) {
245250
RReleaseImage(wwin->net_icon_image);
251+
}
246252

247253
wrelease(wwin);
248254
}

0 commit comments

Comments
 (0)