Possible incorrect use of Xlib functions?
So I have this gui I created in Qt that embeds some X11 windows inside of it (and does a whole bunch of other stuff); when I close the application, I get a seg fault right after/ inside of the last destructor called.
It's entirely possible I missed something in one of the other portions of the gui, but due to the scarce Xlib documentation and the fact that I've been looking for the cause of the fault for a while now, I'm wondering if I'm misusing the Xlib functions.
All I'm doing is creating a few XWindows and displaying stuff in them using a third party library, like so (the following code is called a few times).
On closing the program, the X Windows disappear as you would expect, then right before the seg fault message is printed on the screen, they all pop up for a second then go away..this is why I have a feeling it's the X Windows.
In particular, I couldn't find any good examples on closing them correctly; I'm not sure if XDestroyWindow() should be called before XCloseDisplay().
display = XOpenDisplay (NULL);
scr = ScreenOfDisplay (display, DefaultScreen (display) );
win = XCreateSimpleWindow (display, DefaultRootWindow (display), 0, 0, 320, 240, 0, BlackPixel (display, DefaultScreen (display)), BlackPixel (display, DefaultScreen (display)));
XMapWindow (display, win);
//displaying stuff in X windows
XDestroyWindow (display, win);