2.7.2 ok?

Francesco Montorsi f18m_cpp217828 at yahoo.it
Tue Oct 31 05:58:33 PST 2006


Francesco Montorsi ha scritto:
> Francesco Montorsi ha scritto:
>> Vadim Zeitlin ha scritto:
>>> On Tue, 31 Oct 2006 13:02:58 +0100 Francesco Montorsi 
>>> <f18m_cpp217828 at yahoo.it> wrote:
>>>
>>> FM> The wxTextCtrl is not placed correctly now in the main frame
>>>
>>>  This is a bug in vertical/whatever toolbar patch, sorry. Fixing it 
>>> right
>>> now (fixed already, in fact, but need to test).
>>>
>>> FM> choose "controls" dialog it crashes in wxRadioBox::DoGetBestSize.
>>>
>>>  Fixed this too.
>>>
>>>  The remaining problem is the wrong menu item bitmaps background/lack of
>>> transparency. If you could look into this, I'd appreciate it.
>> I'm looking into it now.
>> hope to solve it in few minutes.
> ok - fixed.
> 
> Patch attached.
> 
> Note that maybe I've found an older problem in the copy constructor 
> which I've marked with a FIXME.
> 
> Also I think some comments like the one "don't copy the bitmap data, but 
> do copy the size, depth, ..." were not much sensed (as one line below 
> the bitmap data was copied).
> 
> I also changed ownerdrawn to use SelectObjectAsSource() as performance 
> optimization (after my patch it was causing a lot of uneeded UnShares).
> 
> It would be nice however to refactor the code and have a single 
> CopyHBITMAP() function since I see that in wxDIB and wxBitmap, wxMask 
> code that's a pretty common use.
> 
> Francesco
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Index: include/wx/msw/bitmap.h
> ===================================================================
> RCS file: /pack/cvsroots/wxwidgets/wxWidgets/include/wx/msw/bitmap.h,v
> retrieving revision 1.58
> diff -b -u -2 -r1.58 bitmap.h
> --- include/wx/msw/bitmap.h	2006/10/30 19:26:02	1.58
> +++ include/wx/msw/bitmap.h	2006/10/31 13:25:14
> @@ -199,4 +199,7 @@
>      wxMask();
>  
> +    // Copy constructor
> +    wxMask(const wxMask &mask);
> +
>      // Construct a mask from a bitmap and a colour indicating the transparent
>      // area
> Index: src/msw/bitmap.cpp
> ===================================================================
> RCS file: /pack/cvsroots/wxwidgets/wxWidgets/src/msw/bitmap.cpp,v
> retrieving revision 1.150
> diff -b -u -2 -r1.150 bitmap.cpp
> --- src/msw/bitmap.cpp	2006/10/29 20:37:33	1.150
> +++ src/msw/bitmap.cpp	2006/10/31 13:41:29
> @@ -206,7 +206,11 @@
>  #endif
>  
> -    // can't copy the mask as the other bitmap destroys it
> +    // (deep) copy the mask if present
>      m_bitmapMask = NULL;
> +    if (data.m_bitmapMask)
> +        m_bitmapMask = new wxMask(*data.m_bitmapMask);
>  
> +    // FIXME: shouldn't we copy the m_hBitmap handle too ?
> +
>      wxASSERT_MSG( !data.m_isDIB,
>                      _T("can't copy bitmap locked for raw access!") );
> @@ -261,9 +265,15 @@
>          wxDIB dib((HBITMAP)(data->m_hBitmap));
>          self->CopyFromDIB(dib);
> +
> +        wxBitmapRefData *selfdata = wx_static_cast(wxBitmapRefData *, self->m_refData);
> +        wxASSERT(selfdata);     // something is very wrong if this fails!
> +
> +        // (deep) copy also the mask
> +        selfdata->SetMask(new wxMask(*data->GetMask()));
just noticed this is very unsafe.
Please replace it with

wxMask *tocopy = data->GetMask();
if (tocopy)
    selfdata->SetMask(new wxMask(tocopy));


Thanks,
Francesco





More information about the wx-dev mailing list