mettli / guichan

Automatically exported from code.google.com/p/guichan
Other
0 stars 0 forks source link

TextField and AllegroImage::free() Enhancements #45

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
AllegroImage::free() destroys a BITMAP* without nullifying the pointer 
afterwards.  It is a 
convention to always set a pointer to null after it the memory it is 
referencing is destroyed.  
AllegroImageLoader sets the autoFree flag to true and if someone was unaware of 
that and tried 
to free the AllegroImage themselves you end up trying to delete memory that has 
already been 
deleted, causing your program to crash.  A fix to this is to fail-safe the 
function with this 
modification:
void AllegroImage::free() 
{ 
  if( mBitmap != NULL )
  {
    destroy_bitmap( mBitmap ); 
    mBitmap = NULL; 
  } 
} 

Also, TextField could be enhanced by adding an editable flag, followed by two 
methods 
isEditable() and setEditable( bool ).  Possibly even adding the flag into the 
constructor.  You can 
get the same effect by using a Label but there may be some instances where you 
want to remove 
the edibility of an existing TextField.  I noticed though that TextBox uses 
this yet TextField does 
not.

Original issue reported on code.google.com by Matt.Dal...@gmail.com on 1 May 2008 at 3:39

GoogleCodeExporter commented 9 years ago
I did not see anything that allowed me to set the type of this issue and change 
it to Enhancement.

Original comment by Matt.Dal...@gmail.com on 1 May 2008 at 3:41

GoogleCodeExporter commented 9 years ago
AllegroImage::free() safety issue has been fixed in revision 1082.

Original comment by b.lindeijer on 5 May 2008 at 9:24

GoogleCodeExporter commented 9 years ago
Added gcn::TextField::setEditable() in revision 1085.

Original comment by b.lindeijer on 15 May 2008 at 2:51