Cleanup colormaps upon exiting the game; bug #1149

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3765 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
avolkov
2012-02-12 19:10:15 +00:00
parent f87f956cdf
commit 2cf7861674
4 changed files with 35 additions and 7 deletions
+25 -5
View File
@@ -64,6 +64,10 @@ static int mapcount;
static Mutex maplock;
static void release_colormap (TFB_ColorMap *map);
static void delete_colormap (TFB_ColorMap *map);
void
InitColorMaps (void)
{
@@ -84,13 +88,23 @@ InitColorMaps (void)
void
UninitColorMaps (void)
{
int i;
TFB_ColorMap *next;
for (i = 0; i < MAX_COLORMAPS; ++i)
{
TFB_ColorMap *map = colormaps[i];
if (!map)
continue;
release_colormap (map);
colormaps[i] = 0;
}
// free spares
for ( ; poolhead; poolhead = next)
for ( ; poolhead; poolhead = next, --poolcount)
{
next = poolhead->next;
HFree (poolhead);
delete_colormap (poolhead);
}
DestroyMutex (fadeLock);
@@ -155,6 +169,13 @@ clone_colormap (TFB_ColorMap *from, int index)
return map;
}
static void
delete_colormap (TFB_ColorMap *map)
{
FreeNativePalette (map->palette);
HFree (map);
}
static inline void
free_colormap (TFB_ColorMap *map)
{
@@ -172,8 +193,7 @@ free_colormap (TFB_ColorMap *map)
}
else
{ // don't need any more spares
FreeNativePalette (map->palette);
HFree (map);
delete_colormap (map);
}
}
@@ -193,7 +213,7 @@ get_colormap (int index)
return map;
}
static inline void
static void
release_colormap (TFB_ColorMap *map)
{
if (!map)
+7
View File
@@ -635,6 +635,13 @@ TFB_PurgeDanglingGraphics (void)
HFree (data);
break;
}
case TFB_DRAWCOMMANDTYPE_IMAGE:
{
TFB_ColorMap *cmap = DC.data.image.colormap;
if (cmap)
TFB_ReturnColorMap (cmap);
break;
}
case TFB_DRAWCOMMANDTYPE_SENDSIGNAL:
{
ClearSemaphore (DC.data.sendsignal.sem);
+1 -1
View File
@@ -99,7 +99,7 @@ UnbatchGraphics (void)
been processed. */
void
FlushGraphics ()
FlushGraphics (void)
{
TFB_DrawScreen_WaitForSignal ();
}
+2 -1
View File
@@ -467,9 +467,10 @@ main (int argc, char *argv[])
// Not yet: TFB_UninitInput ();
unInitAudio ();
uninit_communication ();
UninitColorMaps ();
// TODO: Merge into TFB_UninitGraphics when it goes live
TFB_PurgeDanglingGraphics ();
// Purge above refers to colormaps which have to be still up
UninitColorMaps ();
// Not yet: TFB_UninitGraphics ();
#ifdef NETPLAY