summaryrefslogtreecommitdiff
path: root/openbox/debug.c
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2011-10-06 10:03:52 -0400
committerDana Jansens <danakj@orodu.net>2011-10-06 12:01:30 -0400
commit303cbe76dc2dc273cd7e68a5eaf96c2af3b5d7ab (patch)
treecceb0953d299e07fb76e6ba23aea9aa151fa84f3 /openbox/debug.c
parenta23954ec17c17259f75e0f4e647975bbf4ede058 (diff)
Don't show prompts inside the message handler to prevent recursion
Showing prompts causes messages to be created which causes the glib message handler to abort(). Save the messages and show them when done all other processing for the current event.
Diffstat (limited to 'openbox/debug.c')
-rw-r--r--openbox/debug.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/openbox/debug.c b/openbox/debug.c
index 358b090b..ad083b17 100644
--- a/openbox/debug.c
+++ b/openbox/debug.c
@@ -38,6 +38,8 @@ static guint rr_handler_id = 0;
static guint obt_handler_id = 0;
static guint ob_handler_id = 0;
static guint ob_handler_prompt_id = 0;
+static GList *prompt_queue = NULL;
+static gboolean allow_prompts = TRUE;
static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
const gchar *message, gpointer user_data);
@@ -134,8 +136,8 @@ static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
static void prompt_handler(const gchar *log_domain, GLogLevelFlags log_level,
const gchar *message, gpointer data)
{
- if (ob_state() == OB_STATE_RUNNING)
- prompt_show_message(message, "Openbox", _("Close"));
+ if (ob_state() == OB_STATE_RUNNING && allow_prompts)
+ prompt_queue = g_list_prepend(prompt_queue, g_strdup(message));
else
log_handler(log_domain, log_level, message, data);
}
@@ -184,3 +186,16 @@ void ob_debug_type(ObDebugType type, const gchar *a, ...)
log_argv(type, a, vl);
va_end(vl);
}
+
+void ob_debug_show_prompts(void)
+{
+ if (prompt_queue) {
+ allow_prompts = FALSE; /* avoid recursive prompts */
+ while (prompt_queue) {
+ prompt_show_message(prompt_queue->data, "Openbox", _("Close"));
+ g_free(prompt_queue->data);
+ prompt_queue = g_list_delete_link(prompt_queue, prompt_queue);
+ }
+ allow_prompts = TRUE;
+ }
+}