[wxPython-users] using wxImage in C++ python extension

Josiah Carlson jcarlson at uci.edu
Tue Aug 15 11:27:21 PDT 2006


I should probably clarify a bit.  The pointer that buffer b holds points
to memory that is no longer associated with any array object.  It may or
may not have been freed, which may or may not induce a segfault on
access.

 - Josiah

Josiah Carlson <jcarlson at uci.edu> wrote:
> 
> Depending on the implementation of the object that the buffer points to,
> that may not matter.
> 
> >>> import array
> >>> a = array.array('B', 'a')
> >>> b = buffer(a)
> >>> ia = a.buffer_info()[0]
> >>> while ia == a.buffer_info()[0]:
> ...     a.extend(a)
> ...
> >>> c = buffer(a)
> >>> b
> <read-only buffer for 0x0077A158, ptr 0x007B1DD8, size 1 at 0x007DAAC0>
> >>> c
> <read-only buffer for 0x0077A158, ptr 0x008135C0, size 32 at 0x007DAD40>
> >>> len(a)
> 32
> >>>
> 
> Christopher Barker <Chris.Barker at noaa.gov> wrote:
> > Robin Dunn wrote:
> > > There is also the wx.Image.SetDataBuffer 
> > > method, which will have the wxImage use the buffer passed in without 
> > > making a copy, but if the buffer doesn't live as long as the image does 
> > > it will likely cause a crash.
> > 
> > Could the reference count of the Buffer object be Py_INCREF() when 
> > SetDataBuffer() is called, then Py_DECREF() when the wx.Image is destroyed?
> > 
> > -CHB
> > 
> > 
> > 
> > -- 
> > Christopher Barker, Ph.D.
> > Oceanographer
> >                                      		
> > NOAA/OR&R/HAZMAT         (206) 526-6959   voice
> > 7600 Sand Point Way NE   (206) 526-6329   fax
> > Seattle, WA  98115       (206) 526-6317   main reception
> > 
> > Chris.Barker at noaa.gov
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> > For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org





More information about the wxpython-users mailing list