wxNativePixelData assert on cocoa

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
bcteh
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Nov 27, 2006 9:56 am

wxNativePixelData assert on cocoa

Post by bcteh » Wed Dec 19, 2012 2:47 pm

Hi,

For wx 2.94, when used
wxNativePixelData data(bmp);

It cause below assert error, It is safe to comment out this assert message at ../../src/osx/core/bitmap.cpp(380) ?
I didn't saw any difference at my application, if i just ignore this message.

../../src/osx/core/bitmap.cpp(380): assert "m_rawAccessCount == 0" failed in BeginRawAccess().
Collecting stack trace information, please wait...../../src/osx/core/bitmap.cpp(401): assert "m_rawAccessCount == 1" failed in EndRawAccess().

It work on window and linux.

User avatar
doublemax
Moderator
Moderator
Posts: 14300
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxNativePixelData assert on cocoa

Post by doublemax » Thu Dec 20, 2012 3:08 am

Ignoring asserts is usually not a good idea. But without seeing code it's impossible to tell what causes it.
Use the source, Luke!

bcteh
Experienced Solver
Experienced Solver
Posts: 72
Joined: Mon Nov 27, 2006 9:56 am

Re: wxNativePixelData assert on cocoa

Post by bcteh » Sun Dec 23, 2012 11:44 am

Thank for advices.

I check on wxwidgets source, only found m_rawAccessCount variable on osx/core/bitmaps.cpp
It assign m_rawAccessCount = 0 on Init();
Increase on BeginRawAccess() and decrease on EndRawAccess()

When declare wxNativePixelData xxx(bmp);
the flow go to BeginRowAccess.
May be that is a bug, i didn't see others place for assigning this variable.
For my temporary solution, i just comment it :oops:

Code: Select all

void *wxBitmapRefData::BeginRawAccess()
{
    wxCHECK_MSG( IsOk(), NULL, wxT("invalid bitmap") ) ;
    wxASSERT( m_rawAccessCount == 0 ) ;
#ifndef __WXOSX_IPHONE__
    wxASSERT_MSG( m_pictHandle == NULL && m_iconRef == NULL ,
        wxT("Currently, modifing bitmaps that are used in controls already is not supported") ) ;
#endif
    ++m_rawAccessCount ;

    // we must destroy an existing cached image, as
    // the bitmap data may change now
    if ( m_cgImageRef )
    {
        CGImageRelease( m_cgImageRef ) ;
        m_cgImageRef = NULL ;
    }

    return m_memBuf.GetData() ;
}

void wxBitmapRefData::EndRawAccess()
{
    wxCHECK_RET( IsOk() , wxT("invalid bitmap") ) ;
    wxASSERT( m_rawAccessCount == 1 ) ;

    --m_rawAccessCount ;
}

User avatar
doublemax
Moderator
Moderator
Posts: 14300
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxNativePixelData assert on cocoa

Post by doublemax » Sun Dec 23, 2012 12:09 pm

Actually i meant your code. Somehow you manage to get the access counter out of sync.
Use the source, Luke!

Post Reply