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:
@@ -587,3 +587,42 @@ TFB_FlushGraphics (void)
|
||||
RenderedFrames++;
|
||||
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 ();
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ extern float FrameRate;
|
||||
extern int FrameRateTickBase;
|
||||
|
||||
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 ScreenHeight;
|
||||
|
||||
@@ -470,6 +470,8 @@ main (int argc, char *argv[])
|
||||
unInitAudio ();
|
||||
uninit_communication ();
|
||||
UninitColorMaps ();
|
||||
// TODO: Merge into TFB_UninitGraphics when it goes live
|
||||
TFB_PurgeDanglingGraphics ();
|
||||
// Not yet: TFB_UninitGraphics ();
|
||||
|
||||
#ifdef NETPLAY
|
||||
|
||||
Reference in New Issue
Block a user