move jpeg context freeing to a Deinitialise function instead of ~Image. Turn down the logging

This commit is contained in:
Isaac Connor
2016-10-07 11:33:25 -04:00
parent 96b5af9021
commit 37a4c67ae6
4 changed files with 29 additions and 29 deletions

View File

@@ -152,11 +152,13 @@ Image::Image( const Image &p_image )
strncpy( text, p_image.text, sizeof(text) );
}
Image::~Image()
{
Image::~Image() {
DumpImgBuffer();
if ( initialised )
{
}
/* Should be called as part of program shutdown to free everything */
void Image::Deinitialise() {
if ( initialised ) {
/*
delete[] y_table;
delete[] uv_table;
@@ -166,30 +168,25 @@ Image::~Image()
delete[] b_u_table;
*/
initialised = false;
}
if ( readjpg_dcinfo )
{
jpeg_destroy_decompress( readjpg_dcinfo );
delete readjpg_dcinfo;
readjpg_dcinfo = 0;
}
if ( decodejpg_dcinfo )
{
jpeg_destroy_decompress( decodejpg_dcinfo );
delete decodejpg_dcinfo;
decodejpg_dcinfo = 0;
}
#if 0
+// This creates a memleak because it isn't de-allocating the structures and it's doing it on every Image construct/destruct.
+// We need to refactor this code big time.
for ( unsigned int quality=0; quality <= 100; quality += 1 ) {
if ( writejpg_ccinfo[quality] ) {
delete writejpg_ccinfo[quality];
writejpg_ccinfo[quality] = NULL;
if ( readjpg_dcinfo ) {
jpeg_destroy_decompress( readjpg_dcinfo );
delete readjpg_dcinfo;
readjpg_dcinfo = 0;
}
} // end foreach quality
#endif
if ( decodejpg_dcinfo )
{
jpeg_destroy_decompress( decodejpg_dcinfo );
delete decodejpg_dcinfo;
decodejpg_dcinfo = 0;
}
for ( unsigned int quality=0; quality <= 100; quality += 1 ) {
if ( writejpg_ccinfo[quality] ) {
jpeg_destroy_compress( writejpg_ccinfo[quality] );
delete writejpg_ccinfo[quality];
writejpg_ccinfo[quality] = NULL;
}
} // end foreach quality
}
}
void Image::Initialise()

View File

@@ -150,8 +150,6 @@ protected:
int holdbuffer; /* Hold the buffer instead of replacing it with new one */
char text[1024];
protected:
static void Initialise();
public:
Image();
@@ -159,6 +157,8 @@ public:
Image( int p_width, int p_height, int p_colours, int p_subpixelorder, uint8_t *p_buffer=0);
Image( const Image &p_image );
~Image();
static void Initialise();
static void Deinitialise();
inline unsigned int Width() const { return( width ); }
inline unsigned int Height() const { return( height ); }

View File

@@ -198,6 +198,7 @@ int main( int argc, char *argv[] )
{
fprintf( stderr, "Can't find monitor with id of %d\n", id );
}
Image::Deinitialise();
logTerm();
zmDbClose();
return( 0 );

View File

@@ -358,6 +358,8 @@ int main( int argc, char *argv[] )
delete [] next_delays;
delete [] last_capture_times;
Image::Deinitialise();
logTerm();
zmDbClose();