Re: [PyQt] pyuic4 problem

2010-08-05 Thread William Kyngesburye

On Aug 5, 2010, at 9:18 PM, David Quinn wrote:

> Thanks for the advice, William.
> 
> I followed the instructions for installation (though I could not find
> all the files to delete).

It's possible some files may be in /usr/bin and /usr/include.  (which files did 
you not find?)

> I now received the following error message:
> 
> david$ pyuic4
> Traceback (most recent call last):
>  File "/Library/Python/2.6/site-packages/PyQt4/uic/pyuic.py", line 4,
> in 
>from PyQt4 import QtCore
> ImportError: dlopen(/Library/Python/2.6/site-packages/PyQt4/QtCore.so,
> 2): Symbol not found: _sipQtConnect
>  Referenced from: /Library/Python/2.6/site-packages/PyQt4/QtCore.so
>  Expected in: flat namespace
> in /Library/Python/2.6/site-packages/PyQt4/QtCore.so
> 

Just to make sure - rebuild *both* sip and pyqt, with clean source would help.  
And Qt Cocoa is a must (not the Carbon version) for 64bit.  If your using 
Carbon, don't add --arch=x86_64 for SIP, and use the --use-arch=i386 option for 
PyQt.

... I didn't want to comment, but I also notice your use of Fink.  Are you 
running the system python or from Fink?

My compile instructions should build both 32 abd 64bit SIP and PyQt, so it 
shouldn't matter if you somehow run Python 32bit instead of the default 64bit.  
Check the binaries to make sure:

  file /Library/Python/2.6/site-packages/PyQt4/QtCore.so
  file /Library/Python/2.6/site-packages/sip.so

> My .bash_profile looks like this:
> 
> # Setting PATH for MacPython 2.6
> # The orginal version is saved in .bash_profile.pysave
> PATH="/System/Library/Frameworks/Python.framework/Versions/2.6/bin:${PATH}"
> export PATH
> 
No need if you use the /usr/local and /Library/Python install locations.


P.S.  I also noticed your "qgis_scratch".  Are your developing a plugin for 
Qgis?  I make the "official" Qgis binaries which include a bundled Qt/PyQt, and 
if there is something that I could do with the distribution to help, let me 
know (like adding the sip/pyqt executables and includes).  I didn't think about 
that possibility. Though I do purposely strip out the Qt includes to save space.

... h 

-
William Kyngesburye 
http://www.kyngchaos.com/

[Trillian]  What are you supposed to do WITH a maniacally depressed robot?

[Marvin]  You think you have problems?  What are you supposed to do if you ARE 
a maniacally depressed robot?  No, don't try and answer, I'm 50,000 times more 
intelligent than you and even I don't know the answer...

- HitchHiker's Guide to the Galaxy


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] pyuic4 problem

2010-08-05 Thread David Quinn
Thanks for the advice, William.

I followed the instructions for installation (though I could not find
all the files to delete). I now received the following error message:

david$ pyuic4
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/PyQt4/uic/pyuic.py", line 4,
in 
from PyQt4 import QtCore
ImportError: dlopen(/Library/Python/2.6/site-packages/PyQt4/QtCore.so,
2): Symbol not found: _sipQtConnect
  Referenced from: /Library/Python/2.6/site-packages/PyQt4/QtCore.so
  Expected in: flat namespace
 in /Library/Python/2.6/site-packages/PyQt4/QtCore.so

My .bash_profile looks like this:

# Setting PATH for MacPython 2.6
# The orginal version is saved in .bash_profile.pysave
PATH="/System/Library/Frameworks/Python.framework/Versions/2.6/bin:${PATH}"
export PATH

# set path to be default mac python (2.6)
#PATH="/Library/usr/bin/python:${PATH}"
#export PATH

test -r /sw/bin/init.sh && . /sw/bin/init.sh

# The orginal version is saved in .bash_profile.pysave
PYTHONPATH="/Users/david/Apps/PyQt-4.7.3:${PYTHONPATH}"
export PYTHONPATH

# Setting PATH for MacPython
# The orginal version is saved in .bash_profile.pysave
PYTHONPATH="/Users/david/Dropbox/qgis_scratch:${PYTHONPATH}"
export PYTHONPATH

# setting PATH for rythmbox
PATH = "/Users/david/Apps/rhythmbox-0.9.3.1:${PATH}"

On Thu, Aug 5, 2010 at 9:06 PM, William Kyngesburye
 wrote:
> By default, sip/pyqt executables (and the module binaries and other parts) 
> install in the system python framework.  This is really not a good idea, as 
> Apple can easily zap things, and as you've found the executables aren't found 
> (the framework is not in the standard shell PATH), and there IS a standard 
> user module path.
>
> A better configuration method is (note also that with Qt Cocoa 4.6 you can 
> compile 64bit):
>
> SIP:
>
> export MACOSX_DEPLOYMENT_TARGET=10.6
> python2.6 configure.py -n -d /Library/Python/2.6/site-packages -b 
> /usr/local/bin -e /usr/local/include -v /usr/local/share/sip --arch=i386 
> --arch=x86_64 -s MacOSX10.6.sdk
> make
> sudo make install
>
> PyQt:
>
> python2.6 configure.py -d /Library/Python/2.6/site-packages -b /usr/local/bin
> make
> sudo make install
>
>
> To use your default system install, add 
> /System/Library/Frameworks/Python.framework/Versions/2.6/bin to your PATH in 
> the Terminal.
>
> To clean up the system install, delete:
>
> /System/Library/Frameworks/Python.framework/Versions/2.6/bin/pylupdate4, 
> ptrcc4, pyuic4, sip
> /System/Library/Frameworks/Python.framework/Versions/2.6/include/sip.h
> /System/Library/Frameworks/Python.framework/Versions/2.6/share/sip
> /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/sip*,
>  PyQt4
>
>
> On Aug 5, 2010, at 7:36 PM, David Quinn wrote:
>
>> I've successfully installed SIP and PyQt on a mac running snow leopard
>> using the following commands (courtesy of 
>> http://www.expobrain.net/2010/06/22/install-pyqt4-in-snow-leopard):
>> Within SIP
>> $ export MACOSX_DEPLOYMENT_TARGET=10.6
>> $ python configure.py -n  --arch=i386 -s MacOSX10.6.sdk
>> $ make
>> $ sudo make install
>>
>> Within PyQt4:
>>
>> $ export QTDIR=/Developer/Applications/Qt
>> $ python configure.py --use-arch=i386
>> $ make
>> $ sudo make install
>>
>> When I run Python, I can import PyQt4. However pyuic4 is not installed as 
>> far as I can tell as I get the error message:
>>
>> -bash: pyuic4: command not found
>>
>> when I try to convert a .ui into a .py file.
>>
>> I edited my .bash_profile as I previously had another version of Python and 
>> this is what it currently is:
>>
>> # set path to be default mac python (2.6)
>> PATH="/Library/usr/bin/python:${PATH}"
>> export PATH
>>
>> test -r /sw/bin/init.sh && . /sw/bin/init.sh
>>
>> # The orginal version is saved in .bash_profile.pysave
>> PYTHONPATH="/Users/david/Apps/PyQt-4.7.3:${PYTHONPATH}"
>> export PYTHONPATH
>>
>> # Setting PATH for MacPython
>> # The orginal version is saved in .bash_profile.pysave
>> PYTHONPATH="/Users/david/Dropbox/qgis_scratch:${PYTHONPATH}"
>> export PYTHONPATH
>>
>> Do I need to change a path setting for pyuic4 to work? I previously had 
>> pyuic4 and PyQt working on Python 2.5 before reinstalling everything on 
>> python 2.6.1
>>
>> David
>>
>> ___
>> PyQt mailing list    p...@riverbankcomputing.com
>> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> -
> William Kyngesburye 
> http://www.kyngchaos.com/
>
> "This is a question about the past, is it? ... How can I tell that the past 
> isn't a fiction designed to account for the discrepancy between my immediate 
> physical sensations and my state of mind?"
>
> - The Ruler of the Universe
>
>
> ___
> PyQt mailing list    p...@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcompu

Re: [PyQt] pyuic4 problem

2010-08-05 Thread William Kyngesburye
By default, sip/pyqt executables (and the module binaries and other parts) 
install in the system python framework.  This is really not a good idea, as 
Apple can easily zap things, and as you've found the executables aren't found 
(the framework is not in the standard shell PATH), and there IS a standard user 
module path.

A better configuration method is (note also that with Qt Cocoa 4.6 you can 
compile 64bit):

SIP:

export MACOSX_DEPLOYMENT_TARGET=10.6
python2.6 configure.py -n -d /Library/Python/2.6/site-packages -b 
/usr/local/bin -e /usr/local/include -v /usr/local/share/sip --arch=i386 
--arch=x86_64 -s MacOSX10.6.sdk
make
sudo make install

PyQt:

python2.6 configure.py -d /Library/Python/2.6/site-packages -b /usr/local/bin
make
sudo make install


To use your default system install, add 
/System/Library/Frameworks/Python.framework/Versions/2.6/bin to your PATH in 
the Terminal.

To clean up the system install, delete:

/System/Library/Frameworks/Python.framework/Versions/2.6/bin/pylupdate4, 
ptrcc4, pyuic4, sip
/System/Library/Frameworks/Python.framework/Versions/2.6/include/sip.h
/System/Library/Frameworks/Python.framework/Versions/2.6/share/sip
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/sip*,
 PyQt4


On Aug 5, 2010, at 7:36 PM, David Quinn wrote:

> I've successfully installed SIP and PyQt on a mac running snow leopard
> using the following commands (courtesy of 
> http://www.expobrain.net/2010/06/22/install-pyqt4-in-snow-leopard):
> Within SIP
> $ export MACOSX_DEPLOYMENT_TARGET=10.6
> $ python configure.py -n  --arch=i386 -s MacOSX10.6.sdk
> $ make
> $ sudo make install
> 
> Within PyQt4:
> 
> $ export QTDIR=/Developer/Applications/Qt
> $ python configure.py --use-arch=i386
> $ make
> $ sudo make install
> 
> When I run Python, I can import PyQt4. However pyuic4 is not installed as far 
> as I can tell as I get the error message:
> 
> -bash: pyuic4: command not found
> 
> when I try to convert a .ui into a .py file. 
> 
> I edited my .bash_profile as I previously had another version of Python and 
> this is what it currently is:
> 
> # set path to be default mac python (2.6)
> PATH="/Library/usr/bin/python:${PATH}"
> export PATH
> 
> test -r /sw/bin/init.sh && . /sw/bin/init.sh
> 
> # The orginal version is saved in .bash_profile.pysave
> PYTHONPATH="/Users/david/Apps/PyQt-4.7.3:${PYTHONPATH}"
> export PYTHONPATH
> 
> # Setting PATH for MacPython
> # The orginal version is saved in .bash_profile.pysave
> PYTHONPATH="/Users/david/Dropbox/qgis_scratch:${PYTHONPATH}"
> export PYTHONPATH
> 
> Do I need to change a path setting for pyuic4 to work? I previously had 
> pyuic4 and PyQt working on Python 2.5 before reinstalling everything on 
> python 2.6.1
> 
> David
> 
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

-
William Kyngesburye 
http://www.kyngchaos.com/

"This is a question about the past, is it? ... How can I tell that the past 
isn't a fiction designed to account for the discrepancy between my immediate 
physical sensations and my state of mind?"

- The Ruler of the Universe


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] pyuic4 problem

2010-08-05 Thread David Quinn
I've successfully installed SIP and PyQt on a mac running snow leopard
using the following commands (courtesy of
http://www.expobrain.net/2010/06/22/install-pyqt4-in-snow-leopard):

Within SIP
$ export MACOSX_DEPLOYMENT_TARGET=10.6
$ python configure.py -n  --arch=i386 -s MacOSX10.6.sdk
$ make
$ sudo make install

Within PyQt4:
$ export QTDIR=/Developer/Applications/Qt
$ python configure.py --use-arch=i386
$ make
$ sudo make install

When I run Python, I can import PyQt4. However pyuic4 is not installed as
far as I can tell as I get the error message:

-bash: pyuic4: command not found

when I try to convert a .ui into a .py file.

I edited my .bash_profile as I previously had another version of Python and
this is what it currently is:

# set path to be default mac python (2.6)
PATH="/Library/usr/bin/python:${PATH}"
export PATH

test -r /sw/bin/init.sh && . /sw/bin/init.sh

# The orginal version is saved in .bash_profile.pysave
PYTHONPATH="/Users/david/Apps/PyQt-4.7.3:${PYTHONPATH}"
export PYTHONPATH

# Setting PATH for MacPython
# The orginal version is saved in .bash_profile.pysave
PYTHONPATH="/Users/david/Dropbox/qgis_scratch:${PYTHONPATH}"
export PYTHONPATH

Do I need to change a path setting for pyuic4 to work? I previously had
pyuic4 and PyQt working on Python 2.5 before reinstalling everything on
python 2.6.1

David
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Segmentation faults

2010-08-05 Thread Luke Campagnola
On Thu, Aug 5, 2010 at 03:43, Phil Thompson wrote:

> On Thu, 5 Aug 2010 03:10:50 -0400, Luke Campagnola
> 
> wrote:
> > I believe I have run into a class of bugs in PyQt4. I originally found
> that
> > QSpinBox.lineEdit() returns a QLineEdit instance which does not maintain
> > its
> > reference count properly after the original QSpinBox is deleted. Thus it
> is
> > possible to either 1) have uncollectable LineEdits lingering in memory,
> or
> > 2) crash the program by accessing the LineEdit (see example below).
> >
> > The same bug also applies to:
> >  - QAbstractSpinBox.lineEdit
> >  - QComboBox.lineEdit,
> >  - QAbstractScrollArea.horizontalScrollBar
> >  - QAbstractScrollArea.verticalScrollBar
> >  - QTreeView.header
> >  - QSplitter.handle
> >
> > .. and likely many others. In the best case, this bug causes minor
> memory
> > leaks that few people are likely to notice. In the worst case, it causes
> > crashes which are very difficult to debug if you don't have easy access
> to
> > debugging symbols (ie using windows binaries).
> >
> > $ python
>  from PyQt4.QtGui import *
>  a = QApplication([])
>  s = QSpinBox()
>  l = s.lineEdit()
>  del s
>  l.text()
> > Segmentation fault
>
> These are refer to objects created (and still owned) by C++. They are
> destroyed by C++ when (for example) the QSpinBox is deleted. There is
> nothing that can be done about that.
>

Agreed; Qt may delete objects whenever it pleases. The real issue is that 1)
the reference count for these objects is incorrect, causing memory leaks,
and 2) the object is not informed when it's underlying C++ object is
deleted, which raises the possibility of crashes (raising an exception would
be perfectly acceptable). The former issue is unavoidable, and the latter
(in my opinion) is a serious problem affecting the usability of PyQt. There
are a few rare instances when I think a segmentation fault through python is
acceptable; this is not one of them.

Because they are created by C++, PyQt cannot (easily) work out when they
> get deleted. If it could then you would get an exception about the C++
> object no longer existing instead of a crash.


Given that the original SpinBox object had the correct reference count and
knew when the underlying object had been deleted, there should be a way to
accomplish the same behavior with the LineEdit. I am not familiar with sip
internals, but it seems this could be done by wrapping the SpinBox.lineEdit
function to ensure that the returned object is configured properly, or the
SpinBox itself could call sip.setdeleted on the LineEdit as soon as the
underlying object is deleted. My current workaround is to call
sip.setdeleted from within SpinBox.__del__, but this is obviously not
guaranteed to be called after the underlying object is deleted.

Luke
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Problems creating QApplication instance (backdoor in addTypeSlots)

2010-08-05 Thread Phil Thompson
On Wed, 4 Aug 2010 15:11:46 +, Marcin Cieslak 
wrote:
> Hello,
> 
> I am pretty new to Qt4 and SIP but I try to find a problem
> with the startup of the Py-Qt4 application (Hewlett Packard
> printer toolbox utility from hp-lip package) on my FreeBSD box.
> 
> My environment:
> 
> * FreeBSD 9.0-CURRENT #5 r206987: Tue Apr 27 20:45:03 CEST 2010
> * Qt 4.6.3
> * PyQt4 4.7.3 (configure options at the end of this email)
> * SIP 4.10.2 (configure options at the end of this email)
> * Python 2.5.5
> 
> Everything running on amd64 (64 bit), installed via FreeBSD
> ports from source.
> 
> Simple "from PyQt4.QtGui import QApplication" fails with SIGSEGV:
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 800e041c0 (LWP 100167)]
> 0x0008057a666e in addTypeSlots (heap_to=0x8010c3020, slots=0x53)
>  at siplib.c:9361
> 9361while ((f = slots->psd_func) != NULL)
> (gdb) bt
> #0  0x0008057a666e in addTypeSlots (heap_to=0x8010c3020, slots=0x53)
>  at siplib.c:9361
> #1  0x0008057a790c in sipEnumType_alloc (self=0x8058acc20, nitems=0)
>  at siplib.c:10496
> #2  0x0044eeac in type_new ()
> #3  0x00446c8a in type_call ()
> #4  0x00414fef in PyObject_Call ()
> #5  0x00080579fca8 in createContainerType (cod=0x801c89508,
>  td=0x801c894e0, bases=0x801082410, metatype=0x8058acc20,
>  mod_dict=0x800fb1160, client=0x801b3d300) at siplib.c:5231
> #6  0x0008057a0059 in createClassType (client=0x801b3d300,
>  ctd=0x801c894e0, mod_dict=0x800fb1160) at siplib.c:5350
> #7  0x000805795ad1 in sip_api_init_module (client=0x801b3d300,
>  mod_dict=0x800fb1160) at siplib.c:1381
> #8  0x000801580db7 in initQtGui ()
> from /usr/local/lib/python2.5/site-packages/PyQt4/QtGui.so
> 
> I have poked around a bit and I have trouble understanding one thing
> in siplib.c:
> 
> createContainerType() uses a "currentType" global variable to pass
> the QApplication class description to the object being created by
> Python. An "sip.enumtyp" Python object is being created and then
> sipEnumType_alloc() attempts to use currentType to fill in the slots
> of the object.  However, it assumes that the currentType passed is
> a pointer to (sipEnumTypeDef), while in this case it is
(sipClassTypeDef).
> Segmentation violation occurs when attepting to use illegal value of
> "etd_pyslots" as a pointer.
> 
> How is "currentType" supposed to work in case of metaclass
initialization?

I don't see how that backtrace could be produced in the first place as
sipEnumType_alloc() would never be called in that situation. I assume
something has already gone wrong before the call to PyObject_Call().

In tonight's snapshot I've changed things so that an assert() will fail if
there is an attempt to use the back door recursively - but it works fine
for me.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] New style signals question

2010-08-05 Thread Phil Thompson
On Wed, 04 Aug 2010 20:33:24 +0100, Baz Walter  wrote:
> On 04/08/10 20:25, Phil Thompson wrote:
>> On Wed, 04 Aug 2010 20:20:11 +0100, Baz Walter  wrote:
>>> On 04/08/10 20:07, Phil Thompson wrote:
 Specific overloads are obtained by indexing the bound signal with the
 signature you want, so...

 act.triggered[()].connect(self.myslot)
>>>
>>> can you explain why i see errors like this when using that syntax:
>>>
>>> File "menusys.py", line 1522, in __init__
>>>   self.triggered[()].connect(handler)
>>> TypeError: focusNextChild() has no overload that is compatible with
>>> triggered()
>>
>> That exception message makes no sense in that context. Do you have a
test
>> case?
> 
>  >>> from PyQt4 import QtGui
>  >>> app = QtGui.QApplication([])
>  >>> act = QtGui.QAction(app)
>  >>> wgt = QtGui.QWidget()
>  >>> act.triggered[()].connect(wgt.focusNextChild)
> Traceback (most recent call last):
>File "", line 1, in 
> TypeError: focusNextChild() has no overload that is compatible with 
> triggered()

Fixed in tonight's PyQt snapshot - thanks.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] question about dip models and dip io

2010-08-05 Thread Darren Dale
On Thu, Aug 5, 2010 at 10:59 AM, Phil Thompson
 wrote:
> On Thu, 5 Aug 2010 10:13:27 -0400, Darren Dale  wrote:

[...]

>> Is there any documentation available on dynamically creating a new model
>> type?
>
> You do it just like you would for any other Python type by calling its
> meta-type...
>
> from dip.model import MetaModel, Model, Int
>
> my_dynamic_type = MetaModel('MyDynamicType', (Model, ),
> dict(my_int_attr=Int))
>
> my_instance = my_dynamic_type(my_int_attr=10)
>
> # This will raise an exception...
> my_instance.my_int_attr = 'bad'
>
> You will have to use the current dip snapshot as I hadn't exposed
> MetaModel as part of the dip.model in v0.1.

Great, thank you!
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] question about dip models and dip io

2010-08-05 Thread Phil Thompson
On Wed, 4 Aug 2010 17:57:12 -0400, Darren Dale  wrote:
> At the lab where I work, we generate ascii data files that contain an
> hierarchy of data. The hierarchy and the contents of the table can
> vary. I am trying to understand if it is possible to use dip to
> provide an interface to such data. I was thinking that each node in
> the hierarchy might be accessed via a dip Model, but I need to
> construct the Model based on the contents of the data file. I wondered
> how well this might integrate with dip's design, so I made a slight
> change to one of the tests in the dip test suite to experiment with
> dynamically specifying the attributes of a model:
> 
> 
> diff -r ae63e1237a24 test/tests/dip_io/test_xml.py
> --- a/test/tests/dip_io/test_xml.py   Mon Jul 26 09:20:08 2010 -0400
> +++ b/test/tests/dip_io/test_xml.py   Wed Aug 04 17:27:49 2010 -0400
> @@ -142,7 +142,9 @@
>  """ Test an Instance attribute. """
> 
>  class Klass(Model):
> -attr = Instance(SubModel)
> +#attr = Instance(SubModel)
> +def __init__(self, attr=None):
> +self.attr = attr
> 
>  storage = storage_factory()
> 
> m_write = Klass(attr=SubModel())
> 
> 
> 
> However, after making this change, this test fails:
> 
> 
> ERROR: test_Instance (tests.dip_io.test_xml.TestModel)
> Test an Instance attribute.
> --
> Traceback (most recent call last):
>   File "/Users/darren/Projects/dip/test/tests/dip_io/test_xml.py",
> line 156, in test_Instance
> self.assertEquals(m_read.attr.value, m_write.attr.value)
> AttributeError: 'NoneType' object has no attribute 'value'

Adding new typed attributes to existing (statically defined) models isn't
currently supported, though it could be. An alternative approach would be
to create a new model type dynamically.

> We work on a lot of different kinds of projects, and the experiments
> are constantly changing. As a result, we are unfortunately very
> closely tied to the details of the storage format. Still, it would be
> nice to have an interface that can read one format, and write another.
> Is this possible to do this with dip, given my unusual circumstances?

Yes is the short answer, but I don't understand enough about your
particular requirements to suggest a specific approach. Also, as the
Roadmap states, proper support for import and export is in the works. It
will use the infrastructure that is already in place, but the higher level
APIs (and GUI interaction) still have to be designed.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Segmentation faults

2010-08-05 Thread Phil Thompson
On Thu, 5 Aug 2010 03:10:50 -0400, Luke Campagnola

wrote:
> I believe I have run into a class of bugs in PyQt4. I originally found
that
> QSpinBox.lineEdit() returns a QLineEdit instance which does not maintain
> its
> reference count properly after the original QSpinBox is deleted. Thus it
is
> possible to either 1) have uncollectable LineEdits lingering in memory,
or
> 2) crash the program by accessing the LineEdit (see example below).
> 
> The same bug also applies to:
>  - QAbstractSpinBox.lineEdit
>  - QComboBox.lineEdit,
>  - QAbstractScrollArea.horizontalScrollBar
>  - QAbstractScrollArea.verticalScrollBar
>  - QTreeView.header
>  - QSplitter.handle
> 
> .. and likely many others. In the best case, this bug causes minor
memory
> leaks that few people are likely to notice. In the worst case, it causes
> crashes which are very difficult to debug if you don't have easy access
to
> debugging symbols (ie using windows binaries).
> 
> $ python
 from PyQt4.QtGui import *
 a = QApplication([])
 s = QSpinBox()
 l = s.lineEdit()
 del s
 l.text()
> Segmentation fault

These are refer to objects created (and still owned) by C++. They are
destroyed by C++ when (for example) the QSpinBox is deleted. There is
nothing that can be done about that.

Because they are created by C++, PyQt cannot (easily) work out when they
get deleted. If it could then you would get an exception about the C++
object no longer existing instead of a crash. Either way, the real problem
is a bug in your code.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QValidator.validate() returns TypeError: invalid result type

2010-08-05 Thread Phil Thompson
On Wed, 4 Aug 2010 21:22:47 -0400, Eric Frederich
 wrote:
> Reading the documentation here...
> 
>
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qvalidator.html
> 
> ... I see that the validate() function is listed twice.
> One returning (State, QString, int) and another returning just (State,
int)
> I would think this means I have the choice to return either 2-tuple or a
> 3-tuple.
> 
> Returning a 2-tuple seems to work fine but I get an error trying to
return
> (State, QString, and int)
> 
> Is this a bug, or did I miss something or interpret the documentation
> wrong?

The documentation is describing the API for both the QString v1 and v2
APIs.

The way to get the correct signature for any method is to use help()...

help(QValidator.validate)

The generated docstrings will be correct (for the default QString API).
Changing the documentation so that it is driven from the same information
is on the TODO list.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Object ownership bug in QGraphicsScene::setStyle()

2010-08-05 Thread Phil Thompson
On Thu, 5 Aug 2010 01:03:20 +0200, Max Schwarz  wrote:
> Hi,
> 
> I think I have discovered a bug in PyQt.
> 
> QGraphicsScene.setStyle() does not move ownership of the style to C++,
but
> Qt 
> reparents the style to the scene and deletes it at exit, which causes a 
> segmentation fault if the python interpreter tries to delete it as well.
> 
> See the attachment for a minimal sample.
> 
> I believe line 314 of sip/qgraphicsscene.sip is to blame:
> 
> %If (Qt_4_4_0 -)
> void setStyle(QStyle *);
> %End
> 
> I did not delve deeply into sip, but I think a /Transfer/ annotation is 
> missing.
> 
> My PyQt4 version: 4.7.3-1ubuntu2~lucid1~ppa2 from the kubuntu beta ppa,
I
> did 
> not check if the issue still remains with more current versions.

You're right - thanks.

Phil
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Segmentation faults

2010-08-05 Thread Luke Campagnola
I believe I have run into a class of bugs in PyQt4. I originally found that
QSpinBox.lineEdit() returns a QLineEdit instance which does not maintain its
reference count properly after the original QSpinBox is deleted. Thus it is
possible to either 1) have uncollectable LineEdits lingering in memory, or
2) crash the program by accessing the LineEdit (see example below).

The same bug also applies to:
 - QAbstractSpinBox.lineEdit
 - QComboBox.lineEdit,
 - QAbstractScrollArea.horizontalScrollBar
 - QAbstractScrollArea.verticalScrollBar
 - QTreeView.header
 - QSplitter.handle

.. and likely many others. In the best case, this bug causes minor memory
leaks that few people are likely to notice. In the worst case, it causes
crashes which are very difficult to debug if you don't have easy access to
debugging symbols (ie using windows binaries).

$ python
>>> from PyQt4.QtGui import *
>>> a = QApplication([])
>>> s = QSpinBox()
>>> l = s.lineEdit()
>>> del s
>>> l.text()
Segmentation fault
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt