Skip to content

Commit 68bdaa7

Browse files
committed
FIX: fixed memory leak in window compositor
1 parent 12a1ac1 commit 68bdaa7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/os/win32/host-window.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
199199
for (n = 0; n < MAX_WINDOWS; n++) {
200200
if (Gob_Windows[n].gob == 0) {
201201
Gob_Windows[n].gob = gob;
202-
Gob_Windows[n].compositor = OS_Create_Compositor(Gob_Root, gob);
202+
// note: don't create compositor here,
203+
// it will be done when its class is registered
203204
return n;
204205
}
205206
}
@@ -261,7 +262,7 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
261262
for (n = 0; n < MAX_WINDOWS; n++) {
262263
if (Gob_Windows[n].gob == gob) {
263264
OS_Destroy_Compositor(Gob_Windows[n].compositor);
264-
Gob_Windows[n].gob = 0;
265+
CLEAR(&Gob_Windows[n], sizeof(Gob_Windows[n]));
265266
return;
266267
}
267268
}
@@ -459,6 +460,9 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
459460
Host_Crash("CreateWindow failed");
460461
}
461462

463+
Gob_Windows[windex].win = window;
464+
Gob_Windows[windex].compositor = OS_Create_Compositor(Gob_Root, gob);
465+
462466
if (!Default_Font) {
463467
LOGFONTW font;
464468
HTHEME *hTheme = NULL;
@@ -488,9 +492,6 @@ static REBCNT Get_Widget_Text(HWND widget, REBVAL *text);
488492
if (GET_GOB_FLAG(gob, GOBF_DROPABLE))
489493
DragAcceptFiles(window, TRUE);
490494

491-
Gob_Windows[windex].win = window;
492-
Gob_Windows[windex].compositor = OS_Create_Compositor(Gob_Root, gob);
493-
494495
SET_GOB_FLAG(gob, GOBF_WINDOW);
495496
SET_GOB_FLAG(gob, GOBF_ACTIVE);
496497
SET_GOB_STATE(gob, GOBS_OPEN);

0 commit comments

Comments
 (0)