aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStapleButter <thetotalworm@gmail.com>2018-10-26 18:39:41 +0200
committerStapleButter <thetotalworm@gmail.com>2018-10-26 18:39:41 +0200
commitcbe63f8fd5285022ad3917a675b08b49ee20853c (patch)
treef4dc74f74968ffe70cbf4e2af38d128cc51e35ed
parentc5670a22a59d27d7f4e91c9dd38346ce7288115b (diff)
until we actually get somewhere with the menu crap... fix potential crashes when exiting.
-rw-r--r--src/libui_sdl/libui/unix/area.c4
-rw-r--r--src/libui_sdl/libui/unix/menu.c18
-rw-r--r--src/libui_sdl/main.cpp22
3 files changed, 34 insertions, 10 deletions
diff --git a/src/libui_sdl/libui/unix/area.c b/src/libui_sdl/libui/unix/area.c
index ea31676..40f8624 100644
--- a/src/libui_sdl/libui/unix/area.c
+++ b/src/libui_sdl/libui/unix/area.c
@@ -77,6 +77,10 @@ static void areaWidget_init(areaWidget *aw)
static void areaWidget_dispose(GObject *obj)
{
+ // remove any draw order that might still be pending
+ areaWidget *aw = areaWidget(obj);
+ while (g_idle_remove_by_data(aw->a));
+
G_OBJECT_CLASS(areaWidget_parent_class)->dispose(obj);
}
diff --git a/src/libui_sdl/libui/unix/menu.c b/src/libui_sdl/libui/unix/menu.c
index aa6458f..07cd7b3 100644
--- a/src/libui_sdl/libui/unix/menu.c
+++ b/src/libui_sdl/libui/unix/menu.c
@@ -13,7 +13,6 @@ struct uiMenu {
GArray *items; // []*uiMenuItem
gboolean ischild;
guint id;
- gboolean freed;
};
struct uiMenuItem {
@@ -100,6 +99,22 @@ static void menuItemEnableDisable(uiMenuItem *item, gboolean enabled)
g_hash_table_iter_init(&iter, item->windows);
while (g_hash_table_iter_next(&iter, &widget, NULL))
gtk_widget_set_sensitive(GTK_WIDGET(widget), enabled);
+
+ // extra crummy code for disabling submenus
+ // TODO: find a better way to do it!!!!!!!!!!!!!!!!!!!!!!!!!!
+ // noting that:
+ // * set_sensitive on the menu item does nothing (herpderp)
+ // * set_sensitive on the submenu disables all the submenu items at once (but then you can't fucking enable them back!!)
+ // * googling gives no results, guess nobody has ever wanted to do this shit or...??????
+ // * under Windows we can just disable the menu item and call it good! works exactly as intended!
+ // * fucking stupid pile of shit
+
+ /*if (item->popupchild != NULL)
+ {
+ g_hash_table_iter_init(&iter, item->windows);
+ while (g_hash_table_iter_next(&iter, &widget, NULL))
+ gtk_widget_set_sensitive(GTK_WIDGET(gtk_menu_item_get_submenu(widget)), enabled);
+ }*/
}
void uiMenuItemEnable(uiMenuItem *item)
@@ -276,7 +291,6 @@ uiMenu *uiNewMenu(const char *name)
m->name = g_strdup(name);
m->items = g_array_new(FALSE, TRUE, sizeof (uiMenuItem *));
m->ischild = FALSE;
- m->freed = FALSE;
return m;
}
diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp
index d778753..db8b317 100644
--- a/src/libui_sdl/main.cpp
+++ b/src/libui_sdl/main.cpp
@@ -335,8 +335,6 @@ int EmuThreadFunc(void* burp)
}
else
{
- EmuStatus = 2;
-
// paused
nframes = 0;
lasttick = SDL_GetTicks();
@@ -344,7 +342,13 @@ int EmuThreadFunc(void* burp)
lastmeasuretick = lasttick;
fpslimitcount = 0;
- uiAreaQueueRedrawAll(MainDrawArea);
+ if (EmuRunning == 2)
+ {
+ uiAreaQueueRedrawAll(MainDrawArea);
+ }
+
+ EmuStatus = EmuRunning;
+
SDL_Delay(100);
}
}
@@ -792,6 +796,8 @@ void Stop(bool internal)
if (!internal) // if shutting down from the UI thread, wait till the emu thread has stopped
while (EmuStatus != 2);
RunningSomething = false;
+
+ uiWindowSetTitle(MainWindow, "melonDS " MELONDS_VERSION);
uiMenuItemDisable(MenuItem_SaveState);
uiMenuItemDisable(MenuItem_LoadState);
@@ -1026,11 +1032,8 @@ void UndoStateLoad()
int OnCloseWindow(uiWindow* window, void* blarg)
{
- if (RunningSomething)
- {
- EmuRunning = 2;
- while (EmuStatus != 2);
- }
+ EmuRunning = 3;
+ while (EmuStatus != 3);
uiQuit();
return 1;
@@ -1065,6 +1068,9 @@ void OnLoseFocus(uiWindow* window, void* blarg)
void OnCloseByMenu(uiMenuItem* item, uiWindow* window, void* blarg)
{
+ EmuRunning = 3;
+ while (EmuStatus != 3);
+
uiControlDestroy(uiControl(window));
uiQuit();
}