diff --git a/unix/window.c b/unix/window.c index e6874269..1fce3869 100644 --- a/unix/window.c +++ b/unix/window.c @@ -48,8 +48,9 @@ static void windowDestroy(uiControl *c) // now destroy the bin // the bin has no parent, so we can just call uiControlDestroy() uiControlDestroy(uiControl(w->bin)); - // now destroy the menus - freeMenubar(w->menubar); + // now destroy the menus, if any + if (w->menubar != NULL) + freeMenubar(w->menubar); // now destroy ourselves // this will also free the vbox gtk_widget_destroy(w->widget); diff --git a/windows/window.c b/windows/window.c index 7b461318..0e8f9820 100644 --- a/windows/window.c +++ b/windows/window.c @@ -6,6 +6,7 @@ struct window { uiWindow w; HWND hwnd; + HMENU menubar; uiContainer *bin; int hidden; BOOL shownOnce; @@ -226,7 +227,6 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) RECT adjust; WCHAR *wtitle; BOOL hasMenubarBOOL; - HMENU hmenu; w = uiNew(struct window); @@ -260,8 +260,8 @@ uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar) binSetParent(w->bin, (uintptr_t) (w->hwnd)); if (hasMenubar) { - hmenu = makeMenubar(); - if (SetMenu(w->hwnd, hmenu) == 0) + w->menubar = makeMenubar(); + if (SetMenu(w->hwnd, w->menubar) == 0) logLastError("error giving menu to window in uiNewWindow()"); }