don't crash if an image is not found
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20208 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -406,7 +406,7 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
|
||||
image.Destroy();
|
||||
|
||||
image.LoadFile( dir + _T("test.png") );
|
||||
if ( image.LoadFile( dir + _T("test.png") ) )
|
||||
my_square = new wxBitmap( image );
|
||||
|
||||
image.Destroy();
|
||||
@@ -549,6 +549,8 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
|
||||
// test image loading from stream
|
||||
wxFile file(dir + _T("horse.bmp"));
|
||||
if ( file.IsOpened() )
|
||||
{
|
||||
off_t len = file.Length();
|
||||
void *data = malloc(len);
|
||||
if ( file.Read(data, len) != len )
|
||||
@@ -564,6 +566,7 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
||||
MyCanvas::~MyCanvas()
|
||||
{
|
||||
|
Reference in New Issue
Block a user