Install Atoms before initializing gtk
authorQuentin Rameau <quinq@fifth.space>
Sun, 12 Feb 2017 17:50:31 +0000 (18:50 +0100)
committerQuentin Rameau <quinq@fifth.space>
Wed, 22 Mar 2017 16:20:36 +0000 (17:20 +0100)
There a race condition in gtkplug/socket which is raised when setting
Atoms.
Use this workaround until
https://bugzilla.gnome.org/show_bug.cgi?id=778680 is fixed.

surf.c

diff --git a/surf.c b/surf.c
index cd0a13c..93a1629 100644 (file)
--- a/surf.c
+++ b/surf.c
@@ -271,18 +271,20 @@ setup(void)
        if (signal(SIGHUP, sighup) == SIG_ERR)
                die("Can't install SIGHUP handler");
 
-       gtk_init(NULL, NULL);
-
-       gdpy = gdk_display_get_default();
-       dpy = GDK_DISPLAY_XDISPLAY(gdpy);
-
-       curconfig = defconfig;
+       if (!(dpy = XOpenDisplay(NULL)))
+               die("Can't open default display");
 
        /* atoms */
        atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False);
        atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False);
        atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False);
 
+       gtk_init(NULL, NULL);
+
+       gdpy = gdk_display_get_default();
+
+       curconfig = defconfig;
+
        /* dirs and files */
        cookiefile = buildfile(cookiefile);
        scriptfile = buildfile(scriptfile);
@@ -901,6 +903,7 @@ cleanup(void)
        g_free(scriptfile);
        g_free(stylefile);
        g_free(cachedir);
+       XCloseDisplay(dpy);
 }
 
 WebKitWebView *