summaryrefslogtreecommitdiff
path: root/src/drivers/X11
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2023-10-07 17:14:11 +0200
committerAlbrecht Schlosser <albrechts.fltk@online.de>2023-10-07 17:14:11 +0200
commit1fd6f0dd3af3183c0b41b94eae1379f8e60f3d96 (patch)
treedb2c9bc3c39df84a63b9d66f6d135857b6edaae9 /src/drivers/X11
parentf6690a974245407c5d266dcb688db694e51a3bb4 (diff)
Fix STR 3458: "GLUT compatibility mode segfaults"
... "when there's no current window". Silently ignore GLUT function calls that need a current window if the current window is NULL, return 0 from functions that return an 'int'. Check if window is shown in Fl_X11_Gl_Window_Driver::swap_buffers(). This would issue "XRequest.nnn: GLXBadDrawable 0x0" on X11 otherwise. Note: the chosen implementation to ignore GLUT calls silently appears to be compatible with GLUT (3.7) whereas FreeGLUT 3.0 would issue error messages and exit. The latter could be implemented as well but would be much more work.
Diffstat (limited to 'src/drivers/X11')
-rw-r--r--src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx b/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx
index bbcebbd84..3f09edae2 100644
--- a/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx
+++ b/src/drivers/X11/Fl_X11_Gl_Window_Driver.cxx
@@ -388,6 +388,8 @@ int Fl_X11_Gl_Window_Driver::mode_(int m, const int *a) {
}
void Fl_X11_Gl_Window_Driver::swap_buffers() {
+ if (!fl_xid(pWindow)) // window not shown
+ return;
glXSwapBuffers(fl_display, fl_xid(pWindow));
}