win32: safer threading logic in shutdown sequence
This commit is contained in:
parent
7219f88382
commit
11e417f55a
|
@ -827,6 +827,7 @@ volatile int currDisplayBuffer=-1;
|
||||||
volatile int newestDisplayBuffer=-2;
|
volatile int newestDisplayBuffer=-2;
|
||||||
GMutex *display_mutex = NULL;
|
GMutex *display_mutex = NULL;
|
||||||
GThread *display_thread = NULL;
|
GThread *display_thread = NULL;
|
||||||
|
volatile bool display_die = false;
|
||||||
|
|
||||||
static void DoDisplay_DrawHud()
|
static void DoDisplay_DrawHud()
|
||||||
{
|
{
|
||||||
|
@ -901,11 +902,18 @@ void displayProc()
|
||||||
void displayThread(void*)
|
void displayThread(void*)
|
||||||
{
|
{
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
if(display_die) return;
|
||||||
displayProc();
|
displayProc();
|
||||||
Sleep(10); //don't be greedy and use a whole cpu core, but leave room for 60fps
|
Sleep(10); //don't be greedy and use a whole cpu core, but leave room for 60fps
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KillDisplay()
|
||||||
|
{
|
||||||
|
display_die = true;
|
||||||
|
g_thread_join(display_thread);
|
||||||
|
}
|
||||||
|
|
||||||
void Display()
|
void Display()
|
||||||
{
|
{
|
||||||
CallRegisteredLuaFunctions(LUACALL_AFTEREMULATIONGUI);
|
CallRegisteredLuaFunctions(LUACALL_AFTEREMULATIONGUI);
|
||||||
|
@ -1185,10 +1193,6 @@ fps=0;
|
||||||
Sleep(100);
|
Sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpDDClipPrimary!=NULL) IDirectDraw7_Release(lpDDClipPrimary);
|
|
||||||
if (lpPrimarySurface != NULL) IDirectDraw7_Release(lpPrimarySurface);
|
|
||||||
if (lpBackSurface != NULL) IDirectDraw7_Release(lpBackSurface);
|
|
||||||
if (lpDDraw != NULL) IDirectDraw7_Release(lpDDraw);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1890,6 +1894,13 @@ int _main()
|
||||||
|
|
||||||
delete MainWindow;
|
delete MainWindow;
|
||||||
|
|
||||||
|
KillDisplay();
|
||||||
|
|
||||||
|
if (lpDDClipPrimary!=NULL) IDirectDraw7_Release(lpDDClipPrimary);
|
||||||
|
if (lpPrimarySurface != NULL) IDirectDraw7_Release(lpPrimarySurface);
|
||||||
|
if (lpBackSurface != NULL) IDirectDraw7_Release(lpBackSurface);
|
||||||
|
if (lpDDraw != NULL) IDirectDraw7_Release(lpDDraw);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue