mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-22 20:45:13 +00:00
d2aa572a94
The current GLUT initialization logic is flawed because it allows the QB64 code portion of the program to start on a separate thread at the same time that the GLUT code is starting. This results in a race where some commands won't work for a brief period at the beginning of the program (with "won't work" being very inconsistent, some return invalid values, some have a chance at seg faulting). The same issue also leads to us adding many `while (!window_exists)` checks in an attempt to solve this race for some of the commands. Unfortunately this solution is very inconsistently applied leading to some deadlock situations, and really it's a silly solution when this race is entirely our creation anyway. To fix this, the logic was changed such that we perform all of the GLUT initialization besides calling `glutMainLoop()` before we ever start the thread that runs the actual QB64 code. By doing it this way we ensure that the GLUT initialization has already taken place before the code runs and thus the race is gone. Things get a bit more interesting with $SCREENHIDE, because that simply delays the execution of the GLUT initialization indefinitely until _ScreenShow is done. This was previously very buggy since some commands rely on FreeGLUT being up and will simply hang the entire program if run. Other commands have logic to catch this and simply return zero. The above issue is solved with the `NEEDS_GLUT()` and `OPTIONAL_GLUT()` macros. Both of them simply check if the GLUT initialization has taken place and exit the current function if it has not. The difference between the two is that `NEEDS_GLUT()` throws an 'illegal function call' error while `OPTIONAL_GLUT()` simply exits with no error. The choice of behavior of each function was based upon its previous behavior - if it checked `screen_hide` and exited with no error previously, then `OPTIONAL_GLUT()` was used. If it deadlocked or similar then `NEEDS_GLUT()` was used (so instead of deadlocking, it now produces an error). In this way, programs can now never get stuck due to the use of `$SCREENHIDE` and all the commands have consistent behavior that can be relied upon. Fixes: #234 |
||
---|---|---|
.. | ||
libqb | ||
parts | ||
.gitignore | ||
common.h | ||
libqb.cpp | ||
libqb.h | ||
libqb.mm | ||
msbin.c | ||
mtri1.cpp | ||
mtri1s.cpp | ||
mtri1t.cpp | ||
mtri1ts.cpp | ||
mtri2.cpp | ||
mtri2s.cpp | ||
mtri2t.cpp | ||
mtri2ts.cpp | ||
mtri3.cpp | ||
mtri3s.cpp | ||
mtri3t.cpp | ||
mtri3ts.cpp | ||
mtri4.cpp | ||
mtri4s.cpp | ||
mtri4t.cpp | ||
mtri4ts.cpp | ||
myip.cpp | ||
os.h | ||
purge_all_precompiled_content.bat | ||
purge_all_precompiled_content.command | ||
purge_all_precompiled_content.sh | ||
qbx.cpp | ||
time64.c | ||
time64.h |