From: <mcm...@us...> - 2012-01-10 07:20:40
|
Revision: 3743 http://sc2.svn.sourceforge.net/sc2/?rev=3743&view=rev Author: mcmartin Date: 2012-01-10 07:20:33 +0000 (Tue, 10 Jan 2012) Log Message: ----------- Cleanup: purge the DCQ of the data it owns on the way out of the program. Modified Paths: -------------- trunk/sc2/src/libs/graphics/dcqueue.c trunk/sc2/src/libs/graphics/gfx_common.h trunk/sc2/src/uqm.c Modified: trunk/sc2/src/libs/graphics/dcqueue.c =================================================================== --- trunk/sc2/src/libs/graphics/dcqueue.c 2012-01-08 14:15:05 UTC (rev 3742) +++ trunk/sc2/src/libs/graphics/dcqueue.c 2012-01-10 07:20:33 UTC (rev 3743) @@ -587,3 +587,42 @@ 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 (); +} Modified: trunk/sc2/src/libs/graphics/gfx_common.h =================================================================== --- trunk/sc2/src/libs/graphics/gfx_common.h 2012-01-08 14:15:05 UTC (rev 3742) +++ trunk/sc2/src/libs/graphics/gfx_common.h 2012-01-10 07:20:33 UTC (rev 3743) @@ -98,6 +98,7 @@ 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; Modified: trunk/sc2/src/uqm.c =================================================================== --- trunk/sc2/src/uqm.c 2012-01-08 14:15:05 UTC (rev 3742) +++ trunk/sc2/src/uqm.c 2012-01-10 07:20:33 UTC (rev 3743) @@ -470,6 +470,8 @@ unInitAudio (); uninit_communication (); UninitColorMaps (); + // TODO: Merge into TFB_UninitGraphics when it goes live + TFB_PurgeDanglingGraphics (); // Not yet: TFB_UninitGraphics (); #ifdef NETPLAY This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |