summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2007-04-08 23:27:33 -0400
committerRay Strode <rstrode@redhat.com>2007-04-08 23:27:33 -0400
commit3594f0a035002ec08bfdf10cc391bc96222f54bd (patch)
tree75f9cf6d52082b90de760ae88ef36a52256965bb
parentcb0925c5702c5fe76fe02cddf399fc7b9fec3416 (diff)
add a little blurb about error handling
-rw-r--r--HANDLING-X-ERRORS-BETTER38
-rw-r--r--src/pop-demo.c2
2 files changed, 39 insertions, 1 deletions
diff --git a/HANDLING-X-ERRORS-BETTER b/HANDLING-X-ERRORS-BETTER
new file mode 100644
index 0000000..fa15bdc
--- /dev/null
+++ b/HANDLING-X-ERRORS-BETTER
@@ -0,0 +1,38 @@
+One wart in interacting with X is how it Xlib does error handling. If
+you a request on a window and that window gets destroyed after you send
+the request but before it hits the server (or before you send the
+request but you don't realize it) then Xlib will by default print a
+nastygram to the console and call exit(1). Currently, we take a few
+approaches to preventing these errors from causing exits.
+
+1) Avoid them by grabbing the server, checking if a window is alive
+while the server is grabbed, and then acting on the window
+
+2) using gdk_error_trap_push (); ... code that acts on windows here ...;
+gdk_flush (); status = gdk_error_trap_pop ();
+This:
+ - sets up a different error handler so exit(1) doesn't get called,
+ - sends the requests we want sent off, sent off
+ - flushes the request queue and waits for a response
+ - returns any errors that came in after the gdk_flush () call.
+
+Both 1) and 2) are less than optimal. Grabbing the server is something
+that should be avoided whenever possible because it makes the entire
+session (all X applications) stop receiving events and block.
+
+The push () / pop () guards aren't optimal because they force the app to
+synchronize frequently and they can trap other errors than the ones
+expected.
+
+I think there may be a better way. Rather than synchronously trapping
+errors, we could potentially keep track of the request number of each
+request before making it and then wait until the request is processed or
+an error comes back.
+
+One way to potentially handle this would be create a new main loop
+event source.
+
+PopXRequestWatch pop_x_request_watch_source_new (int x_request_id)
+guint pop_x_request_watch_add (int x_request_id)
+
+or something along those lines
diff --git a/src/pop-demo.c b/src/pop-demo.c
index e035d2f..96f687e 100644
--- a/src/pop-demo.c
+++ b/src/pop-demo.c
@@ -407,10 +407,10 @@ main (int argc,
initialize_shape_extension ();
overlay_window = pop_overlay_window_new ();
+#if 0
overlay_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_app_paintable (GTK_WIDGET (overlay_window), TRUE);
gtk_window_set_default_size (GTK_WINDOW (overlay_window), 640, 480);
-#if 0
gtk_widget_realize (GTK_WIDGET (overlay_window));
#endif