Several threads may call gui_exit(), but joining the calling thread doesn't
work in such a case. Hence the thread continues to run and accesses its
previously freed data structures.
The best approach would be to redesign the software to have the main thread
cleanup all data structures. An easier intermediate approach is to have an
independent thread which executes gui_exit() when fired and have the main
thread wait for it.
Popular examples for these issues are for example quitting xine via lirc or
passing it the option -pq to quit after replaying a MRL.
src/xitk/actions.c | 3 +++
src/xitk/common.h | 13 +++++++++++++
src/xitk/main.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 66 insertions(+), 0 deletions(-)