Cleanup: purge the DCQ of the data it owns on the way out of the program.

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3743 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2012-01-10 07:20:33 +00:00
parent 3d32d8ad2c
commit c16883fce4
3 changed files with 42 additions and 0 deletions
+39
View File
@@ -587,3 +587,42 @@ TFB_FlushGraphics (void)
RenderedFrames++; RenderedFrames++;
BroadcastCondVar (RenderingCond); BroadcastCondVar (RenderingCond);
} }
void
TFB_PurgeDanglingGraphics (void)
{
Lock_DCQ (-1);
for (;;)
{
TFB_DrawCommand DC;
if (!TFB_DrawCommandQueue_Pop (&DC))
{
// the Queue is now empty.
break;
}
switch (DC.Type)
{
case TFB_DRAWCOMMANDTYPE_DELETEIMAGE:
{
TFB_Image *DC_image = DC.data.deleteimage.image;
TFB_DrawImage_Delete (DC_image);
break;
}
case TFB_DRAWCOMMANDTYPE_DELETEDATA:
{
void *data = DC.data.deletedata.data;
HFree (data);
break;
}
case TFB_DRAWCOMMANDTYPE_SENDSIGNAL:
{
ClearSemaphore (DC.data.sendsignal.sem);
break;
}
}
}
Unlock_DCQ ();
}
+1
View File
@@ -98,6 +98,7 @@ extern float FrameRate;
extern int FrameRateTickBase; extern int FrameRateTickBase;
void TFB_FlushGraphics (void); // Only call from main thread!! void TFB_FlushGraphics (void); // Only call from main thread!!
void TFB_PurgeDanglingGraphics (void); // Only call from main thread as part of shutdown.
extern int ScreenWidth; extern int ScreenWidth;
extern int ScreenHeight; extern int ScreenHeight;
+2
View File
@@ -470,6 +470,8 @@ main (int argc, char *argv[])
unInitAudio (); unInitAudio ();
uninit_communication (); uninit_communication ();
UninitColorMaps (); UninitColorMaps ();
// TODO: Merge into TFB_UninitGraphics when it goes live
TFB_PurgeDanglingGraphics ();
// Not yet: TFB_UninitGraphics (); // Not yet: TFB_UninitGraphics ();
#ifdef NETPLAY #ifdef NETPLAY