Hi Josh,
The decorator is not a pretty solution either :P
But I needed it to have my dock widgets working both under in-house apps
and Nuke/Maya UI.
Still, I'm wondering if your situation is the same as mine (I got friends
under Suse who do not appear to have the issue...)
Here is the decorator, if you want to try it out.
from functools import wraps
import sip
def AntiSlotCrash(meth):
'''
There is a bug in PyQt under nuke and maya that
make the app crash after a slot received a sip
wrapper in its argument. (When the garbage collector
calls delete on it)
This decorator prevents the crash by avoiding
the sip.delete call on those arguments.
It does not prevent all crashes I guess (like
when you keep a reference to the sip wrapper...)
and is probably a big source of leak, but it
will let us work until new versions of PyQt are
embedded in nuke and maya...
'''
@wraps(meth)
def wrap(self, *args, **kwargs):
ret = meth(self, *args, **kwargs)
for arg in list(args)+kwargs.values():
if isinstance(arg, sip.simplewrapper):
sip.setdeleted(arg)
return ret
return wrap
If you have a chance to give it a try, I'll be interested whether it fixes
it or not.
Cheers!
dee.
.
2011/11/1 Josh Imbruglia <[email protected]>
> Hi Dee,
>
> I'm running on Fedora 8, so it's happening under Linux too. It's not
> the most elegant solution to the problem but does work.
>
> Cheers,
> Josh
>
> On Tue, Nov 1, 2011 at 8:27 AM, Dee Guff <[email protected]> wrote:
> > Hi Nathan, Hi list :)
> >
> > I ran into this too, with PyQt under Nuke and Maya.
> > I *think* it's a windows only bug, what os did you use?
> >
> > Anyway, it took me two days to track it: it's a segfault happening when
> the slot receives an sip object argument.
> > The c++ object dies at the end of the slot w/o deref the python wrapper,
> and when this wrapper gets garbage collected the segfault occurs...
> >
> > I'm using a decorator on my slot too deal with this until the next
> version of qt/sip/PyQt is usable...
> >
> > Hope this can save you time!
> > Cheers,
> > Dee.
> > .
> >
> >
> > Envoyé de mon iPwned
> >
> > Le 31 oct. 2011 à 17:46, Nathan Rusch <[email protected]> a
> écrit :
> >
> >> Try using `self.ui.connect(self.ui, SIGNAL("finished(int)"), lambda x:
> self.finished())`, and redefining your finished method to remove its code
> arg. I just ran into a situation like this where .show() + a non-lambda
> slot method connected to 'finished' caused PyQt to crash silently under
> 6.3+, and I'm curious if it's just something with my configuration.
> >>
> >> -Nathan
> >>
> >>
> >> -----Original Message----- From: Josh Imbruglia
> >> Sent: Monday, October 31, 2011 6:17 AM
> >> To: Nuke Python discussion
> >> Subject: [Nuke-python] PyQt and open() vs exec_() vs show()
> >>
> >> hi everybody,
> >>
> >> I'm having trouble getting anything other then exec_ working to open
> >> my PyQt dialogs under nuke 6.3. I want to make a dialog non-modal but
> >> whenever i use show() to display the dialog none of my connections are
> >> setup. Has anyone else experienced this or found a workaround?
> >>
> >> a brief excerpt of my code is:
> >>
> >> class pyQt_myDialog(object):
> >> def __init__(self):
> >> self.ui = uic.loadUi('myDialog.ui')
> >> self.ui.connect(self.ui, SIGNAL("finished(int)"), self.finished)
> >>
> >> def finished(self, code):
> >> sys.stderr.write('we are finished %s\n' % str(code))
> >>
> >> if i use exec_() to run it i get the printed statement, with open() or
> >> show() nothing gets printed on closing the window. the ui gets loaded
> >> correctly with the loadUi command.
> >>
> >> any help or ideas on making a non-modal pyqt window in nuke6.3 would
> >> be oh so helpful.
> >>
> >> thanks!
> >> Josh
> >> _______________________________________________
> >> Nuke-python mailing list
> >> [email protected], http://forums.thefoundry.co.uk/
> >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
> >> _______________________________________________
> >> Nuke-python mailing list
> >> [email protected], http://forums.thefoundry.co.uk/
> >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
> > _______________________________________________
> > Nuke-python mailing list
> > [email protected], http://forums.thefoundry.co.uk/
> > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
> >
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python