diff --git a/docs/changes.txt b/docs/changes.txt index f1d54ad02f..e5a20fcd1a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -21,6 +21,9 @@ Changes in behaviour not resulting in compilation errors other ports, but this can be unexpected for the applications not expecting their idle handlers to be called from inside wxYield(). +- Creating wxBitmap with 0 width or height now always fails in all ports + (it used to succeed in wxMSW). + Changes in behaviour which may result in build errors ----------------------------------------------------- diff --git a/interface/wx/bitmap.h b/interface/wx/bitmap.h index 8009dad792..c8068a6647 100644 --- a/interface/wx/bitmap.h +++ b/interface/wx/bitmap.h @@ -291,9 +291,16 @@ public: the current colour setting. A depth of 32 including an alpha channel is supported under MSW, Mac and GTK+. + + @param width + The width of the bitmap in pixels, must be strictly positive. + @param height + The height of the bitmap in pixels, must be strictly positive. + @param depth + The number of bits used to represent each bitmap pixel. */ wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); - + /** @overload */ @@ -413,11 +420,18 @@ public: /** Creates a fresh bitmap. If the final argument is omitted, the display depth of the screen is used. - + + @param width + The width of the bitmap in pixels, must be strictly positive. + @param height + The height of the bitmap in pixels, must be strictly positive. + @param depth + The number of bits used to represent each bitmap pixel. + @return @true if the creation was successful. */ virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); - + /** @overload */ diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index f5c76c72e4..b1588b972b 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -536,7 +536,7 @@ wxBitmap::~wxBitmap() bool wxBitmap::Create( int width, int height, int depth ) { UnRef(); - wxCHECK_MSG(width >= 0 && height >= 0, false, "invalid bitmap size"); + wxCHECK_MSG(width > 0 && height > 0, false, "invalid bitmap size"); m_refData = new wxBitmapRefData(width, height, depth); return true; } diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 67d4677658..5603227e7a 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -755,6 +755,8 @@ bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc) { UnRef(); + wxCHECK_MSG( w > 0 && h > 0, false, wxT("invalid bitmap size") ); + m_refData = new wxBitmapRefData; GetBitmapData()->m_width = w; diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index ce38f9eb01..0cfc57b07e 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -1191,6 +1191,8 @@ bool wxBitmap::Create(int w, int h, int d) { UnRef(); + wxCHECK_MSG(w > 0 && h > 0, false, "invalid bitmap size"); + if ( d < 0 ) d = wxDisplayDepth() ;