Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 303cbe76dc2dc273cd7e68a5eaf96c2af3b5d7ab 1 parent a23954e
Dana Jansens danakj authored

Showing 3 changed files with 22 additions and 2 deletions. Show diff stats Hide diff stats

  1. +17 2 openbox/debug.c
  2. +2 0  openbox/debug.h
  3. +3 0  openbox/event.c
19 openbox/debug.c
@@ -38,6 +38,8 @@ static guint rr_handler_id = 0;
38 38 static guint obt_handler_id = 0;
39 39 static guint ob_handler_id = 0;
40 40 static guint ob_handler_prompt_id = 0;
  41 +static GList *prompt_queue = NULL;
  42 +static gboolean allow_prompts = TRUE;
41 43
42 44 static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
43 45 const gchar *message, gpointer user_data);
@@ -134,8 +136,8 @@ static void log_handler(const gchar *log_domain, GLogLevelFlags log_level,
134 136 static void prompt_handler(const gchar *log_domain, GLogLevelFlags log_level,
135 137 const gchar *message, gpointer data)
136 138 {
137   - if (ob_state() == OB_STATE_RUNNING)
138   - prompt_show_message(message, "Openbox", _("Close"));
  139 + if (ob_state() == OB_STATE_RUNNING && allow_prompts)
  140 + prompt_queue = g_list_prepend(prompt_queue, g_strdup(message));
139 141 else
140 142 log_handler(log_domain, log_level, message, data);
141 143 }
@@ -184,3 +186,16 @@ void ob_debug_type(ObDebugType type, const gchar *a, ...)
184 186 log_argv(type, a, vl);
185 187 va_end(vl);
186 188 }
  189 +
  190 +void ob_debug_show_prompts(void)
  191 +{
  192 + if (prompt_queue) {
  193 + allow_prompts = FALSE; /* avoid recursive prompts */
  194 + while (prompt_queue) {
  195 + prompt_show_message(prompt_queue->data, "Openbox", _("Close"));
  196 + g_free(prompt_queue->data);
  197 + prompt_queue = g_list_delete_link(prompt_queue, prompt_queue);
  198 + }
  199 + allow_prompts = TRUE;
  200 + }
  201 +}
2  openbox/debug.h
@@ -38,4 +38,6 @@ void ob_debug_type(ObDebugType type, const gchar *a, ...);
38 38
39 39 void ob_debug_enable(ObDebugType type, gboolean enable);
40 40
  41 +void ob_debug_show_prompts(void);
  42 +
41 43 #endif
3  openbox/event.c
@@ -736,6 +736,9 @@ static void event_process(const XEvent *ec, gpointer data)
736 736 used = event_handle_prompt(prompt, e);
737 737 }
738 738
  739 + /* show any debug prompts that are queued */
  740 + ob_debug_show_prompts();
  741 +
739 742 /* if something happens and it's not from an XEvent, then we don't know
740 743 the time, so clear it here until the next event is handled */
741 744 event_curtime = event_sourcetime = CurrentTime;

0 comments on commit 303cbe7

Please sign in to comment.
Something went wrong with that request. Please try again.