Implement wxMask copy ctor for wxGTK.

Without copy ctor copying masks simply crashed because the same pointer was
deleted twice.

Also added a (completely trivial but better than nothing...) unit test for
wxBitmap to check that copying masks does work now.

Closes #11854.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63774 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-03-28 23:20:49 +00:00
parent 6f4968ce94
commit 27297c823a
13 changed files with 56 additions and 6 deletions

View File

@@ -79,6 +79,23 @@ wxMask::wxMask()
m_bitmap = NULL;
}
wxMask::wxMask(const wxMask& mask)
{
if ( !mask.m_bitmap )
{
m_bitmap = NULL;
return;
}
// create a copy of an existing mask
gint w, h;
gdk_drawable_get_size(mask.m_bitmap, &w, &h);
m_bitmap = gdk_pixmap_new(mask.m_bitmap, w, h, 1);
wxGtkObject<GdkGC> gc(gdk_gc_new(m_bitmap));
gdk_draw_drawable(m_bitmap, gc, mask.m_bitmap, 0, 0, 0, 0, -1, -1);
}
wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour )
{
m_bitmap = NULL;
@@ -859,12 +876,7 @@ wxGDIRefData* wxBitmap::CloneGDIRefData(const wxGDIRefData* data) const
}
if (oldRef->m_mask != NULL)
{
newRef->m_mask = new wxMask;
newRef->m_mask->m_bitmap = gdk_pixmap_new(
oldRef->m_mask->m_bitmap, oldRef->m_width, oldRef->m_height, 1);
wxGtkObject<GdkGC> gc(gdk_gc_new(newRef->m_mask->m_bitmap));
gdk_draw_drawable(newRef->m_mask->m_bitmap,
gc, oldRef->m_mask->m_bitmap, 0, 0, 0, 0, -1, -1);
newRef->m_mask = new wxMask(*oldRef->m_mask);
}
return newRef;