Re: [PyQt] QWebView and https

2010-05-27 Thread Kovid Goyal
Look at the sourcecode from the spynner project, its in python and IIRC does
this.

Kovid.

On Thu, May 27, 2010 at 10:59:52AM -0500, alanm wrote:
> On Thursday 27 May 2010 10:41:08 am David Boddie wrote:
> 
> > You should just be able to set the network access manager on the QWebPage
> > returned by the QWebView's page() method. I don't know if this will do
> > everything you need.
> > 
> > I'm curious about the need to subclass QNetworkAccessManager. I would have
> > thought that simply connecting the sslErrors signal to a slot and calling
> > the ignoreSslErrors() method of the QNetworkReply object passes to it would
> > do what you need. Reimplementing the sslErrors signal in a subclass may not
> > work as you might expect.
> 
> David, thanks for your response.  I've tried both of these approaches, and so 
> far nothing works.  What's really frustrating is it just fails silently, 
> never 
> loading the page, so I'm not sure where I'm going wrong.
> 
> I got the approach of subclassing QNetworkAccessManager from trying to make 
> sense of the arora sourcecode with my limited c++ comprehension.  I'm open to 
> any suggestion, as long as I can make it work; if my approach seems strange 
> it's because I'm flailing around ineptly looking for an answer. :-)
> 
> Here's the code I tried based on your second suggestion:
> 
> self.connect (self.myWebview.page().networkAccessManager(), 
> SIGNAL("sslErrors(QNetworkReply, QList)"), self.sslErrorHandler)
> 
> def sslErrorHandler(self, reply, errorList):
> reply.ignoreSslErrors()
> print errorList
> return
> 
> Is that correct?  The first statement is called in the __init__() function of 
> the mainwindow widget, self.myWebview is just a QWebView().
> 
> I would be extremely grateful if anyone could provide a simple working 
> example.
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4bfe975122499873516082!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


pgpexmI8LbrVr.pgp
Description: PGP signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] PyQt4.QtGui + uuid.uuid4() = segfault

2010-12-10 Thread Kovid Goyal
See http://bugs.gentoo.org/show_bug.cgi?id=317557

Kovid.

On Thu, Dec 09, 2010 at 08:56:18PM -0600, Christopher Singley wrote:
> I'm using PyQt4 v4.7.3.  Check this out:
> 
> Python 2.7.1 (r271:86832, Dec  1 2010, 23:37:45)
> [GCC 4.4.5] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from PyQt4 import QtGui
> >>> import uuid
> >>> uuid.uuid4()
> Segmentation fault
> 
> If I import uuid before QtGui, though, then it works fine.
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4d0196e713992074819977!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


pgpOHKosaQlVs.pgp
Description: PGP signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Hunting down memory leaks

2010-12-14 Thread Kovid Goyal
If you are using lambdas or partials as slots to connect to, you can very 
easily create reference cycles that the garbage collector wont be able to 
clear. For example, say you have a widget with a button and a method 
react_to_button_press and you do something like

class Widget(QWidget):

def __init__(self):
QWidget.__init__(self)

self.button.clicked.connect(partial(self.react_to_button_press, 1))

This means any Widget objects will never be garbage collected, unless you 
explicitly disconnect the signal. 

Kovid.

On Mon, Dec 13, 2010 at 09:49:55PM +1100, Mikael Modin wrote:
> Hi,
> 
> I'm currently developing a little tool and it seems I have a memory
> leak somewhere along the line that handles images, so each leak is
> around 7mb which is kind of a big deal leading my app quickly to
> 100mb. I'm wondering if any of you havea any tips to figure out what
> kind of object I'm leaking and where I'm leaking them. I'm new to
> python, Qt and PyQt so I'm not very well versed in what tools are
> available.
> 
> Kind regards
> Mikael
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4d05fa8d1399204440!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


pgp8gpNVg485Y.pgp
Description: PGP signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Segfault: QGraphicsView, cyclic references, and threads

2011-03-27 Thread Kovid Goyal
: None}, 
> locals=
> {'weakref': , 'QtGui':  0xb7fa44f4>, 'thread': , '__builtins__':  at remote 0xb7fa4074>, '__file__': 'bugtest.py', 'doWork':  remote 0xb7eabd4c>, '__package__': None, 'sys':  0xb7fa408c>, 'time': , 'test':  remote 0xb7eabd14>, '__name__': '__main__', 'app':  0xb7eb042c>, 'QtCore': , '__doc__': None}, 
> closeit=1, flags=0xb32c) at ../Python/pythonrun.c:1325
> #31 0x08100812 in PyRun_SimpleFileExFlags (fp=0x82a1e78, filename=0xb5a8 
> "bugtest.py", closeit=1, flags=0xb32c) at ../Python/pythonrun.c:935
> #32 0x0805de5c in Py_Main (argc=2, argv=0xb414) at ../Modules/main.c:572
> #33 0x0805d03b in main (argc=2, argv=0xb414) at ../Modules/python.c:23
> (gdb) quit

> # -*- coding: utf-8 -*-
> import sys, time, weakref
> #from PySide import QtCore, QtGui  ## bug is not present in PySide
> from PyQt4 import QtCore, QtGui
> 
> app = QtGui.QApplication([])
> 
> def test():
> for c in range(5000):
> if c%100 == 0:
> sys.stdout.write('.')
> sys.stdout.flush()
> 
> ## Create a GraphicsView and an item linking back to it
> w = QtGui.QGraphicsView()
> s = QtGui.QGraphicsScene()
> w.setScene(s)
> i = QtGui.QGraphicsRectItem(0,0,1,1)
> s.addItem(i)
> 
> i.view = w  ## <-- this is crucial
> #i.view = weakref.ref(w)
> 
> app.processEvents()
> print "OK"
>  
> 
> def doWork():
> while True:
> x = '.'.join(['%f'%i for i in range(100)])  ## some work for the 
> thread to do
> if time is None:  ## main thread has started cleaning up, bail out now
> break
> time.sleep(1e-3)
> 
> ## Another thread must be active (python threads and QThreads both work)
> #class Thread(QtCore.QThread):
> #def run(self):
> #doWork()
> #th = Thread()  
> #th.start()
> 
> import thread
> thread.start_new_thread(doWork, ())
> 
> test()
> 
> 

> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4d8ff2b960459713818798!


-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


pgpDWxuY7GBnP.pgp
Description: PGP signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] subtle bug in PyQt in combination with Python garbage collector

2011-08-13 Thread Kovid Goyal
c=0xb70951b4, arg=0xb710154c, kw=0x0) at 
> Objects/abstract.c:2529
> #35 0x00b83484 in instancemethod_call (func=0xb70ef734, arg=0xb710154c, 
> kw=0x0) at Objects/classobject.c:2578
> #36 0x00b7159c in PyObject_Call (func=0xb70ef734, arg=0xb76d402c, kw=0x0) at 
> Objects/abstract.c:2529
> #37 0x00c19b94 in PyEval_CallObjectWithKeywords (func=0xb70ef734, 
> arg=0xb76d402c, kw=0x0) at Python/ceval.c:3881
> #38 0x0093efc0 in sip_api_call_method (isErr=0x0, method=0xb70ef734, 
> fmt=0x721031b "") at siplib.c:1742
> #39 0x0706df2a in sipVH_QtCore_11 (sipGILState=PyGILState_UNLOCKED, 
> sipMethod=0xb70ef734) at sipQtCorecmodule.cpp:4376
> #40 0x070b8664 in sipQThread::run (this=0x97870f0) at sipQtCoreQThread.cpp:165
> #41 0x03c39fef in QThreadPrivate::start (arg=0x97870f0) at 
> thread/qthread_unix.cpp:320
> #42 0x00fc1cc9 in start_thread (arg=0x2d23b70) at pthread_create.c:304
> #43 0x00f1869e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
> 

> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4e465c069887238618555!


-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Bug in QWebKit?...

2012-01-13 Thread Kovid Goyal
In my experience (writing an ebook viewer based on Qt WebKit) disagreements
between DOM and javascript values are *very* common. There's no a priori way to
know which is correct. You have to do it on a case by case basis and be prepared
to have lots of heuristic sanity checks. Furthermore, the things that disagree
and how they disagree change with Qt releases. 

See for example lines 430 to 447 here:
http://bazaar.launchpad.net/~kovid/calibre/trunk/view/head:/src/calibre/gui2/viewer/documentview.py

In short, it's a crapshoot.

Kovid.

On Thu, Jan 12, 2012 at 04:28:17PM -0800, James Polk wrote:
> 
> 
> Greetings All,
> 
> We've uncovered what appears to be a very unfortunate bug in QWebKit...
> If it is indeed a bug, we can't tell _where_ the bug is originating from..
> .is it a Qt-bug? PyQt? We're on Qt 4.7,..could it be fixed in 4.8? (Env info 
> below)
> 
> 
> Essentially what's happening,...is that there is a difference between the data
> that is returned via JavaScript method vs. DOM method.  We're trying to decide
> which one to use, this issue isn't helping, lol...
> 
> When you run the program,...a textField and two buttons are displayed.
>     1. In the textField is "John".
>     2. Hitting Button1 calls a decorator pyqtslot/function that changes the 
> textField to "Mary".
>     3. Hitting Button2 calls a different decorator pyqtslot/function that 
> queries the textField in two ways,
>         one JavaScript, one via DOM.
> 
>     4. JavaScript returns "Mary"
>     DOM returns "John"
> 
> which one's correct?
> 
> (1011)% p test-form.py
> Defaults button:
>   Submit button:
>     Value of Name: field according to javascript: Mary
>     Value of Name: field according to DOM: John
> 
> Here are the decorator slot/functions in question:
> 
> 
>     @QtCore.pyqtSlot()
>     def SetDefault(self):
>     print "Defaults button:"
> 
>     
> self.ui.webView.page().mainFrame().evaluateJavaScript("""document.thisForm.name.value
>  = "Mary";""")
> 
> 
> 
>     @QtCore.pyqtSlot(str)
>     def SubmitButton(self,name_via_javascript):
>     print "  Submit button:"
> 
>     frame = self.ui.webView.page().mainFrame()
>     name_via_dom = frame.findFirstElement("#nameId").attribute("value")
>     print "    Value of Name: field according to javascript: " + 
> name_via_javascript
>     print "    Value of Name: field according to Python/DOM: " + 
> name_via_dom
> 
> 
> 
> If anybody can shed any light on this...and/or has any thoughts or 
> suggestions, we're all ears ;-)
> 
> (Btw,..our test-form.py is a heavily edited version of the distribution 
> example file "formextractor")
> 
> 
> I whittled down the phenomena to two pretty small test files to illustrate 
> the problem..
> 
> Attached as a zipfileone file is .py and the other one is .html
> 
> 
> Environment,..
> 
> OSX Lion 10.7.2
> 
>    Python 2.7.2
>    Qt 4.7.4
>    Sip 4.13
>    PyQt 4.8.6
> 
> 
> Thank you very much,
> Jim
> 
> 
> !DSPAM:3,4f0f7ac816201166415380!


> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4f0f7ac816201166415380!


-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Bug in QWebKit?...

2012-01-13 Thread Kovid Goyal
On Fri, Jan 13, 2012 at 09:34:42AM +0100, Andreas Pakulat wrote:
> Well, determining coordinates and height/width for elements is a
> completely different story than fetching a static attribute from a
> static element in a static page.

The point is that I have found that properties that can be modified in
javascript often return different values when accessed via javascript and the
Qt APIs. 

Static with respect to what? Do the following; in the test case James attached,
click the Submit button without clicking the defaults button first, I'm betting
you will see that the values returned by the two APIs are the same.

Kovid.

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Bug in QWebKit?...

2012-01-13 Thread Kovid Goyal
On Fri, Jan 13, 2012 at 10:32:02AM +0100, Andreas Pakulat wrote:
> Maybe I didn't read your code close enough, but it merely looked like a
> case where different page-contents influence a given attribute in
> different ways. So the code tries to determine which attribute is best
> used for height. This is not uncommon in browsers, layouting HTML is a
> hard business due to varying rules and missing definitions. So it might
> just be that the contentsSize property does not map to the
> body.offsetHeight but uses some other property which is not set
> correctly in some webpages.

The difficulty of laying out HTML is irrelevant. Whatever that difficulty,
WebKit uses a single algorithm for laying out a given set of HTML. In other
words if you layout the same HTML n times, you will deterministically get the
same result n times. So for what you're saying to make sense, the C++ API would
need to query the layout engine in a different way than the javascript engine,
to get the same layout information. Which in turn means that they have 
different memory models of the rendered document. Which is what James' 
example also appears to be suffering from. 

Anyway, I claim that you will find disconnects between the javascript API 
and the C++ API a lot in Qt WebKit, make of that claim whatever you want. 

Kovid.

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Help understanding a backtrace

2012-01-19 Thread Kovid Goyal
Hi all,

I've recently started getting random segfaults in calibre on my dev machine
(linux 64bit sip-4.13.1 and PyQt4-4.9). I compiled everything with -ggdb and
generated the following backtrace from a core dump (Only kept the top 15 calls)

#0  removeFromParent (self=0x5f66cc0) at siplib.c:5265
#1  0x7f6774aa4061 in sip_api_common_dtor (sipSelf=0x5f66cc0) at 
siplib.c:5183
#2  0x7f6774aa76d0 in add_object (om=, addr=0x2f0e740, 
val=0x5ce39f0) at objmap.c:269
#3  0x7f6774aa7a6a in sipOMAddObject (om=0x7f6774caf980, val=0x5ce39f0) at 
objmap.c:163
#4  0x7f6774aa08bd in sipSimpleWrapper_init (self=0x5ce39f0, 
args=0x7f675403a150, kwds=0x0) at siplib.c:9149
#5  0x7f677c34b9f8 in type_call (type=, args=0x7f675403a150, 
kwds=0x0) at Objects/typeobject.c:737
#6  0x7f677c2f65d3 in PyObject_Call (func=0xba2c60, arg=, 
kw=) at Objects/abstract.c:2529
#7  0x7f6779ef9a08 in imap_next (lz=0x5ccfe50) at 
/var/tmp/portage/dev-lang/python-2.7.2-r3/work/Python-2.7.2/Modules/itertoolsmodule.c:1549
#8  0x7f677c321b96 in listextend (self=0x5ccb368, b=) at 
Objects/listobject.c:872
#9  0x7f677c321e18 in list_init (self=0x5ccb368, args=, 
kw=) at Objects/listobject.c:2458
#10 0x7f677c34b9f8 in type_call (type=, args=0x7f675403a750, 
kwds=0x0) at Objects/typeobject.c:737
#11 0x7f677c2f65d3 in PyObject_Call (func=0x7f677c6340e0, arg=, kw=) at Objects/abstract.c:2529
#12 0x7f677c38e23d in do_call (nk=, na=, 
pp_stack=0x7fff9424b6e8, func=0x7f677c6340e0) at Python/ceval.c:4231
#13 call_function (oparg=, pp_stack=0x7fff9424b6e8) at 
Python/ceval.c:4036
#14 PyEval_EvalFrameEx (f=, throwflag=) at 
Python/ceval.c:2666
..
#70 0x7f677555948f in QMetaObject::activate (sender=0x6296e30, m=, local_signal_index=, argv=0x7fff9424d5a0) at 
kernel/qobject.cpp:3278
#71 0x7f6773637b32 in QAction::triggered (this=, _t1=false) 
at .moc/release-shared/moc_qaction.cpp:263
#72 0x7f6773637d2a in QAction::activate (this=0x6296e30, event=) at kernel/qaction.cpp:1257
#73 0x7f67739dda6a in QAbstractButtonPrivate::click (this=0x62972e0) at 
widgets/qabstractbutton.cpp:528
#74 0x7f67739ddd1c in QAbstractButton::mouseReleaseEvent (this=0x6296c80, 
e=0x7fff9424e090) at widgets/qabstractbutton.cpp:1121
#75 0x7f6773a9a57a in QToolButton::mouseReleaseEvent (this=, 
e=) at widgets/qtoolbutton.cpp:721

Now removeFromParent in siplib.c has

static void removeFromParent(sipWrapper *self)
{
if (self->parent != NULL)
{
if (self->parent->first_child == self) <-- this is line 5265
self->parent->first_child = self->sibling_next;

I dont understand how this could segfault, unless the self->parent structure is
corrupted. What circumstances could cause that to happen? Offhand I'd guess the
parent is deleted in Qt, but that is just a guess. 

I'd appreciate some insight from someone more familiar with sip/PyQt. I'll be
happy to provide more information, if needed. The segfaults are rare and seem
to occur at random times. Note that I have disabled cyclic garbage for python
in calibre and run the garbage collection only in the GUI thread, manually, at
fixed intervals. From the backtrace this particular crash appears to
be happening in response to a click event, so the garbage collector doesn't
seem to be involved.

Thanks,

Kovid.

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-01-19 Thread Kovid Goyal
On Thu, Jan 19, 2012 at 06:24:41PM +0100, Erik Janssens wrote:
> FYI, since PyQt 4.9 you don't need to disable the garbage
> collector any more.
> 
> When Python desides to delete a Qt object from a different
> thread, PyQt delayes the deletion until that thread has
> taken control.

I know, I was involved in making that change :) However, I cannot always 
control what version of PyQt calibre runs on and rather than having two
different behaviors based on PyQt version, I left in the old workaround, since
it doesn't do any harm.

Kovid.

-- 
_________

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-01-19 Thread Kovid Goyal
On Thu, Jan 19, 2012 at 05:32:49PM +, Phil Thompson wrote:
> The current version of SIP made some changes to the the mapping between
> Python and C++ objects. It might be worth trying a version without those
> changes. You would need to backout the changes up to and including...
> 
> http://www.riverbankcomputing.com/hg/sip/rev/da88157d2f03
> 
> Phil

I'll do that, thanks. I won't know if the problem is fixed by it or not, for a
while, since the crashes are rather rare, but, I'll run with it for a week or
so and report back.

Kovid.

-- 
_________

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-01-26 Thread Kovid Goyal
It's been a week and I have had no crashes since reverting sip to revision
1027. While that is by no means conclusive proof of a bug, it is highly
suggestive. Is there some extra instrumentation I can add to SIP to narrow down
the cause?

Kovid.

On Thu, Jan 19, 2012 at 10:24:56PM +0530, Kovid Goyal wrote:
> Hi all,
> 
> I've recently started getting random segfaults in calibre on my dev machine
> (linux 64bit sip-4.13.1 and PyQt4-4.9). I compiled everything with -ggdb and
> generated the following backtrace from a core dump (Only kept the top 15 
> calls)
> 
> #0  removeFromParent (self=0x5f66cc0) at siplib.c:5265
> #1  0x7f6774aa4061 in sip_api_common_dtor (sipSelf=0x5f66cc0) at 
> siplib.c:5183
> #2  0x7f6774aa76d0 in add_object (om=, addr=0x2f0e740, 
> val=0x5ce39f0) at objmap.c:269
> #3  0x7f6774aa7a6a in sipOMAddObject (om=0x7f6774caf980, val=0x5ce39f0) 
> at objmap.c:163
> #4  0x7f6774aa08bd in sipSimpleWrapper_init (self=0x5ce39f0, 
> args=0x7f675403a150, kwds=0x0) at siplib.c:9149
> #5  0x7f677c34b9f8 in type_call (type=, 
> args=0x7f675403a150, kwds=0x0) at Objects/typeobject.c:737
> #6  0x7f677c2f65d3 in PyObject_Call (func=0xba2c60, arg=, 
> kw=) at Objects/abstract.c:2529
> #7  0x7f6779ef9a08 in imap_next (lz=0x5ccfe50) at 
> /var/tmp/portage/dev-lang/python-2.7.2-r3/work/Python-2.7.2/Modules/itertoolsmodule.c:1549
> #8  0x7f677c321b96 in listextend (self=0x5ccb368, b=) at 
> Objects/listobject.c:872
> #9  0x7f677c321e18 in list_init (self=0x5ccb368, args=, 
> kw=) at Objects/listobject.c:2458
> #10 0x7f677c34b9f8 in type_call (type=, 
> args=0x7f675403a750, kwds=0x0) at Objects/typeobject.c:737
> #11 0x7f677c2f65d3 in PyObject_Call (func=0x7f677c6340e0, arg= out>, kw=) at Objects/abstract.c:2529
> #12 0x7f677c38e23d in do_call (nk=, na=, 
> pp_stack=0x7fff9424b6e8, func=0x7f677c6340e0) at Python/ceval.c:4231
> #13 call_function (oparg=, pp_stack=0x7fff9424b6e8) at 
> Python/ceval.c:4036
> #14 PyEval_EvalFrameEx (f=, throwflag=) at 
> Python/ceval.c:2666
> ..
> #70 0x7f677555948f in QMetaObject::activate (sender=0x6296e30, 
> m=, local_signal_index=, argv=0x7fff9424d5a0) 
> at kernel/qobject.cpp:3278
> #71 0x7f6773637b32 in QAction::triggered (this=, 
> _t1=false) at .moc/release-shared/moc_qaction.cpp:263
> #72 0x7f6773637d2a in QAction::activate (this=0x6296e30, event= out>) at kernel/qaction.cpp:1257
> #73 0x7f67739dda6a in QAbstractButtonPrivate::click (this=0x62972e0) at 
> widgets/qabstractbutton.cpp:528
> #74 0x7f67739ddd1c in QAbstractButton::mouseReleaseEvent (this=0x6296c80, 
> e=0x7fff9424e090) at widgets/qabstractbutton.cpp:1121
> #75 0x7f6773a9a57a in QToolButton::mouseReleaseEvent (this= out>, e=) at widgets/qtoolbutton.cpp:721
> 
> Now removeFromParent in siplib.c has
> 
> static void removeFromParent(sipWrapper *self)
> {
> if (self->parent != NULL)
> {
> if (self->parent->first_child == self) <-- this is line 5265
> self->parent->first_child = self->sibling_next;
> 
> I dont understand how this could segfault, unless the self->parent structure 
> is
> corrupted. What circumstances could cause that to happen? Offhand I'd guess 
> the
> parent is deleted in Qt, but that is just a guess. 
> 
> I'd appreciate some insight from someone more familiar with sip/PyQt. I'll be
> happy to provide more information, if needed. The segfaults are rare and seem
> to occur at random times. Note that I have disabled cyclic garbage for python
> in calibre and run the garbage collection only in the GUI thread, manually, at
> fixed intervals. From the backtrace this particular crash appears to
> be happening in response to a click event, so the garbage collector doesn't
> seem to be involved.
> 
> Thanks,
> 
> Kovid.
> 
> -- 
> _
> 
> Dr. Kovid Goyal 
> http://www.kovidgoyal.net
> http://calibre-ebook.com
> _



> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4f184afe16202038013821!


-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-01-27 Thread Kovid Goyal
On Fri, Jan 27, 2012 at 10:18:13AM +, Phil Thompson wrote:
> On Fri, 27 Jan 2012 10:21:29 +0530, Kovid Goyal 
> wrote:
> > Just got another crash, this time the backtrace had no itertools call.
> I've
> > attached the full backtrace for both crashes to this mail. How would you
> > like
> > me to proceed? 
> 
> I assume that these are with the change applied.

No this was without the change applied. Sorry, I should have made that clear. 
Simply to confirm that the issue still exists after switching back to current 
SIP. 

I'll now apply your first change and wait for a crash (it might take a while
given how rare the crashes are). If there is a crash, I'll send you the
backtrace and also apply your second change and wait again.

Kovid.

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-01-27 Thread Kovid Goyal
On Thu, Jan 26, 2012 at 03:15:31PM +, Phil Thompson wrote:
> Then can you try the following change to add_object() in objmap.c...
> 
> if (!(val->flags & SIP_SHARE_MAP))
> 
> ...to...
> 
> if (!(val->flags & (SIP_SHARE_MAP | SIP_ALIAS)))
> 
> ...to see if it helps.

I was unable to do this. First, there is no add_object() in objmap.c, instead
there is sipOMAddObject(). Also, SIP_ALIAS is undeclared, grepping the SIP
source code for SIP_ALIAS returns no matches, and making that change and
compiling gives:

objmap.c: In function ‘sipOMAddObject’:
objmap.c:172:46: error: ‘SIP_ALIAS’ undeclared (first use in this function)
 
Kovid.

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-01-28 Thread Kovid Goyal
I did, specifically to a checkout with hg:

hg clone http://www.riverbankcomputing.com/hg/sip/ && grep -r SIP_ALIAS sip/
destination directory: sip
requesting all changes
adding changesets
adding manifests
adding file changes
added 1035 changesets with 2861 changes to 151 files (+7 heads)
updating to branch default
122 files updated, 0 files merged, 0 files removed, 0 files unresolved

Do you mean against the current release tarball?

Kovid.

On Sat, Jan 28, 2012 at 10:36:45AM +, Phil Thompson wrote:
> On Sat, 28 Jan 2012 13:07:42 +0530, Kovid Goyal 
> wrote:
> > On Thu, Jan 26, 2012 at 03:15:31PM +, Phil Thompson wrote:
> >> Then can you try the following change to add_object() in objmap.c...
> >> 
> >> if (!(val->flags & SIP_SHARE_MAP))
> >> 
> >> ...to...
> >> 
> >> if (!(val->flags & (SIP_SHARE_MAP | SIP_ALIAS)))
> >> 
> >> ...to see if it helps.
> > 
> > I was unable to do this. First, there is no add_object() in objmap.c,
> > instead
> > there is sipOMAddObject(). Also, SIP_ALIAS is undeclared, grepping the
> SIP
> > source code for SIP_ALIAS returns no matches, and making that change and
> > compiling gives:
> > 
> > objmap.c: In function ‘sipOMAddObject’:
> > objmap.c:172:46: error: ‘SIP_ALIAS’ undeclared (first use in this
> > function)
> 
> Apply these changes to the current version of SIP.
> 
> Phil
> 
> !DSPAM:3,4f23cfc01859118538!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-01-29 Thread Kovid Goyal
On Sun, Jan 29, 2012 at 11:05:39AM +, Phil Thompson wrote:
> Yes, or the 4.13-maint branch...
> 
> hg update 4.13-maint
> 
> ...which (at the moment) are the same.

OK, done. You'll hear from me in a week if there are no
crashes, sooner otherwise.

Kovid.

-- 
_________

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-01-30 Thread Kovid Goyal
On Sun, Jan 29, 2012 at 10:14:48PM +, Phil Thompson wrote:
> Backout that change and apply the second one.

Doing that results in a crash, with the assertion causing the output

python2: objmap.c:267: add_object: Assertion `sw->flags & 0x0200 == 0' failed.

Backtrace attached.

Kovid.

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_
[New LWP 13034]
[New LWP 13040]
[New LWP 13039]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `python2 /usr/bin/calibre-parallel'.
Program terminated with signal 6, Aborted.
#0  0x7f2335508ac5 in raise () from /lib64/libc.so.6

Thread 3 (Thread 0x7f2312e06700 (LWP 13039)):
#0  0x7f233586e58c in pthread_cond_wait () from /lib64/libpthread.so.0
No symbol table info available.
#1  0x7f2324a3a4d4 in WTF::TCMalloc_PageHeap::runScavengerThread(void*) () 
from /usr/lib64/qt4/libQtWebKit.so.4
No symbol table info available.
#2  0x7f2335869d0c in start_thread () from /lib64/libpthread.so.0
No symbol table info available.
#3  0x7f23355afdbd in clone () from /lib64/libc.so.6
No symbol table info available.

Thread 2 (Thread 0x7f23124ed700 (LWP 13040)):
#0  0x7f23355a6ee3 in poll () from /lib64/libc.so.6
No symbol table info available.
#1  0x7f232e4377c3 in g_main_context_poll (n_fds=1, fds=0x7f230c000be0, 
timeout=-1, context=0x3adc6d0, priority=) at gmain.c:3402
poll_func = 0x7f232e4476e0 
#2  g_main_context_iterate (context=0x3adc6d0, block=1, dispatch=1, 
self=) at gmain.c:3084
max_priority = 2147483647
timeout = -1
some_ready = 
nfds = 1
allocated_nfds = 
fds = 0x7f230c000be0
#3  0x7f232e437c91 in g_main_context_iteration (context=0x3adc6d0, 
may_block=1) at gmain.c:3152
retval = 
#4  0x7f232ecafc8f in QEventDispatcherGlib::processEvents (this=0x3aa4640, 
flags=...) at kernel/qeventdispatcher_glib.cpp:422
d = 0x3ae89a0
canWait = true
result = 
#5  0x7f232ec83f22 in QEventLoop::processEvents (this=, 
flags=...) at kernel/qeventloop.cpp:149
d = 0x7f230c000b10
#6  0x7f232ec8416c in QEventLoop::exec (this=0x7f23124ece80, flags=...) at 
kernel/qeventloop.cpp:201
d = 0x7f230c000b10
app = 0x39903d0
#7  0x7f232eb99724 in QThread::exec (this=) at 
thread/qthread.cpp:498
d = 0x3ae8c50
locker = {val = 61770976}
eventLoop = { = {_vptr.QObject = 0x7f232efb58d0, static 
staticMetaObject = {d = {superdata = 0x0, stringdata = 0x7f232ed400c0 
"QObject", data = 0x7f232ed40160, extradata = 0x7f232efad500}}, d_ptr = {d = 
0x7f230c000b10}, static staticQtMetaObject = {d = {superdata = 0x0, stringdata 
= 0x7f232ed48d20 "Qt", data = 0x7f232ed4c5e0, extradata = 0x0}}}, static 
staticMetaObject = {d = {superdata = 0x7f232efad4e0, stringdata = 
0x7f232ed525a0 "QEventLoop", data = 0x7f232ed525c0, extradata = 0x0}}}
returnCode = 
#8  0x7f232eb9bf85 in QThreadPrivate::start (arg=0x1c6af80) at 
thread/qthread_unix.cpp:331
thr = 0x1c6af80
data = 0x3ae2ff0
#9  0x7f2335869d0c in start_thread () from /lib64/libpthread.so.0
No symbol table info available.
#10 0x7f23355afdbd in clone () from /lib64/libc.so.6
No symbol table info available.

Thread 1 (Thread 0x7f233602b700 (LWP 13034)):
#0  0x7f2335508ac5 in raise () from /lib64/libc.so.6
No symbol table info available.
#1  0x7f2335509f46 in abort () from /lib64/libc.so.6
No symbol table info available.
#2  0x7f233550184e in __assert_fail_base () from /lib64/libc.so.6
No symbol table info available.
#3  0x7f2335501910 in __assert_fail () from /lib64/libc.so.6
No symbol table info available.
#4  0x7f232e1e7348 in add_object (om=0x7f232e3efb80, addr=0x3c2af20, 
val=0x37cff30) at objmap.c:267
next = 0x0
sw = 0x37db7a0
he = 0x1c17830
__PRETTY_FUNCTION__ = "add_object"
#5  0x7f232e1e70d1 in sipOMAddObject (om=0x7f232e3efb80, val=0x37cff30) at 
objmap.c:163
addr = 0x3c2af20
base_ctd = 0x7fff129fd9f0
#6  0x7f232e1e2526 in sipSimpleWrapper_init (self=0x37cff30, 
args=0x7f2335fea050, kwds=0x0) at siplib.c:9149
sipNew = 0x3c2af20
sipFlags = 4
owner = 0x0
wt = 0x1c53ae0
td = 0x7f232f3eb8e0
ctd = 0x7f232f3eb8e0
unused = 0x0
unused_p = 0x0
got_kw_handler = 1
kw_handler = 0x7f232f15dbc0 
__PRETTY_FUNCTION__ = "sipSimpleWrapper_init"
#7  0x7f2335b1f9f8 in type_call (type=, args=0x7f2335fea050, 
kwds=0x0) at Objects/typeobject.c:737
obj = 0x37cff30
#8  0x7f2335aca5d3 in PyObject_Call (func=0x1c53ae0, arg=, 
kw=) at Objects/abstract.c:2529
result = 
call = 0x7f2335b1f980 
#9  0x7f232e1e6cd8 in sipWrapSimpleInst

Re: [PyQt] Help understanding a backtrace

2012-01-30 Thread Kovid Goyal
I was able to trace the python code that is triggering the assert. 

Basically, it is the following sequence:

view = self.parent() 
At this point view is a subclass of QMainWindow and view.parent() returns None
Calling view.size() causes the assert to be triggered. Interestingly the assert
is only triggered the second time this code is run, which tells me that
probably the underlying Qt object corresponding to view has been deleted. view
is the main window of the application, there is reference to it kept at the
python level.

Note that this is only one instance where the assert is triggered, I am fairly
certain that there will be several unrelated code paths throughout calibre that
will trigger it, given the various crashes I have experienced.

Reading the SIP changelog, one thing of note: The QMainWindow subclass has
multiple inheritance. It is defined as

class EbookViewer(MainWindow, Ui_EbookViewer):

where Ui_EbookViewer comes from a compiled .ui file and MainWindow is a simple
subclass of QMainWindow. The definition of EbookViewer is here: 
http://bazaar.launchpad.net/~kovid/calibre/trunk/view/head:/src/calibre/gui2/viewer/main.py#L171
and the MainWindow class is:
http://bazaar.launchpad.net/~kovid/calibre/trunk/view/head:/src/calibre/gui2/main_window.py#L90

Let me know if there's anything else I can do.

Kovid.

On Sun, Jan 29, 2012 at 10:14:48PM +, Phil Thompson wrote:
> On Sun, 29 Jan 2012 22:20:26 +0530, Kovid Goyal 
> wrote:
> > Got another crash, with the addition of SIP_ALIAS. The backtrace is a
> > little
> > different, now the crash happens in PyObject__GcUntrack called from
> > removeParent (backtrace attached).
> > 
> > To be clear this is running off sip 4.13.1 release tarball with the
> first
> > change you asked for (addition of SIP_ALIAS in object_add())
> > 
> > How would you like me to proceed?
> 
> Backout that change and apply the second one.
> 
> Phil
> 
> !DSPAM:3,4f25c4da18598762377731!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-01-30 Thread Kovid Goyal
On Mon, Jan 30, 2012 at 12:22:35PM +, Phil Thompson wrote:
> Try the current tip of the 4.13-maint branch without any additional
> changes...
> 
> hg pull -u

Done, albeit with hg clone -b 4.13-maint instead as pull wasn't doing the right
thing. 

I'll let you know in a week if there are no more crashes, sooner otherwise.

Kovid.

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help understanding a backtrace

2012-02-06 Thread Kovid Goyal
On Mon, Jan 30, 2012 at 12:22:35PM +, Phil Thompson wrote:
> Try the current tip of the 4.13-maint branch without any additional
> changes...

I'm happy to report I have seen no more crashes. I'd appreciate a 4.13.2
release, so I have to deal with fewer calibre randomnly crashing bug reports.

Thanks,

Kovid.

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] multiprocessing with QApplication

2012-06-11 Thread Kovid Goyal
Don't use multiprocessing. multiprocessing is not thread safe, on unix
it uses fork() without exec() which means that it inherits *everything*
from the parent process including locks (which are in an invalid state
in the child process), file handles, global objects like QApplication
and so on. Just as an illustration of the problems multiprocessing can
cause, if you use it with the standard library logging module you can
have your worker processes crash, since the logging module uses locks.

After all, what do you expect to happen to QApplication on fork()?
There's no way for fork() to have the QApplication object magically
re-initialize itself.

Using multiprocessing *will* bite you in the rear on any project of
moderate complexity. Heck it bit me on the rear even while implementing
a muti-core replacment for grep. Instead use subprocess to launch a
worker process, feed it a module name, functions and arguments on stdin
using cPickle or json and then have it run the task. About the only use
cases that I can think of that multiprocessing is suitable for are:

1) Toy examples to demonstrate how "easy" using multiple processes in
python is
2) Performance critical applications where the overhead of launching and
initializing a new python interpreter should be avoided. (And this only on
Unix, since on windows the interpreter has to be restarted anyway).
3) Tasks where the processes need to share memory, which is somewhat
easier to do with multiprocessing than other schemes, though you should
only do this if you *really* know what you are doing and are very
careful about the side-effects of fork.

The one really useful thing in the multiprocessing module is the
Listener and Client classes that allow you to establish easy
communication between your parent and child process. Though even there,
the implementation in multiprocessing is not EINTR safe so you have to
wrap calls to accept(), read(), write() in a wrapper that deals with
EINTR.

Kovid.

On Mon, Jun 11, 2012 at 11:44:27AM -0400, Luke Campagnola wrote:
> Howdy,
> 
> I am trying to use multiprocessing in a PyQt application to spawn an extra
> process with its own GUI. The problem I am running into is that the child
> process seems to be instantiated with a broken QApplication instance that
> causes the child to crash. If I understand multiprocessing correctly, child
> processes will inherit some resources from the parent process (file
> handles, for example) and I suspect this is leading the child process to
> believe it already has a QApplication.
> 
> I have attached a simple script that demonstrates this problem. If the
> child process is spawned before the parent process instantiates its
> QApplication, then everything works as expected. If the parent QApplication
> is created before spawning the child process, then we see that  1) the
> child thinks it already has a QApplication and 2) the program crashes,
> presumably because the QApplication was never properly instantiated by the
> child. (If I try creating a new QApplication in the child then the process
> simply hangs or has other erratic behavior, which is usually the result of
> creating more than one QApplication).
> 
> Any experience / suggestions?
> 
> Thanks,
> Luke
> 
> 
> !DSPAM:3,4fd6128d18074722032819!


> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4fd6128d18074722032819!


-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] multiprocessing with QApplication

2012-06-13 Thread Kovid Goyal
On Mon, Jun 11, 2012 at 01:59:35PM -0400, Luke Campagnola wrote:
> I agree with you about the multiprocessing package--I really only use it
> for the ease of passing python objects between processes. (I use
> multiprocessing.Pipe(), which I believe uses the Listener/Client system you
> mentioned). I'll definitely try using this with subprocess instead. Thanks
> for the EINTR warning; I'm sure that would have taken another hour or two
> for me to work out :)

That's interesting, how are you using Pipe? More specifically, how are
you passing a Connection object to the worker process? Connection
objects cannot be unpickled, at least in python 2.7, see:
http://bugs.python.org/issue4892

Kovid.

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] ANN: PyQt v4.9.2 and SIP v4.13.3 Released

2012-06-22 Thread Kovid Goyal
I find that with PyQt 4.9.2 and SIP 4.13.2 or 4.13.3 calls to
QMainWindow::saveState freeze in *some* circumstances. Reverting to PyQt
4.9.1 fixes the issue. The freezes are happening in a closeEvent
handler (linux 64bit, Qt 4.8.2, compiled from source packages).

I haven't been able to figure out exactly when or produce a simple test
case. But I thought I should document the problem in case other people
experience it.

Kovid.

On Thu, Jun 21, 2012 at 03:21:21PM +0100, Phil Thompson wrote:
> PyQt v4.9.2 and SIP v4.13.3 have been released. From the PyQt NEWS file...
> 
> - Added support for Qt v4.8.2.
> - Added support for Qt v5-alpha (QtCore and QtGui only).
> - Added support for Python v3.3.
> - bool(QPyNullVariant(...)) now returns False rather than True to mimic
>   the behaviour of None.
> - Exposed the pyqtBoundSignal type object in the QtCore module.
> - Added the signal attribute to pyqtBoundSignal containing the signature
>   that would be returned by SIGNAL().
> - Added the optional package argument to uic.loadUi() to properly handle
>   relative imports.
> - pyuic4 now supports themed icons.
> - Added the spreadsheet example from Hans-Peter Jansen.
> 
> Phil
> 
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4fe32df918078536719295!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] ANN: PyQt v4.9.2 and SIP v4.13.3 Released

2012-06-23 Thread Kovid Goyal
On Sat, Jun 23, 2012 at 10:26:08PM +0100, Phil Thompson wrote:
> On Sat, 23 Jun 2012 21:53:48 +0530, Kovid Goyal 
> wrote:
> > On Sat, Jun 23, 2012 at 01:36:42PM +0100, Phil Thompson wrote:
> >> Hmm, hardly anything has changed in PyQt4. Can you try using the...
> >> 
> >> qpy/QtCore/qpycore_pyqtproxy.cpp
> >> 
> >> ...from 4.9.1 in 4.9.2?
> > 
> > Still hangs.
> 
> I'm struggling to think what might have changed. Do you know the line at
> which it hangs? Does it look like a deadlock?

This line: 
http://bazaar.launchpad.net/~kovid/calibre/trunk/view/head:/src/calibre/gui2/viewer/main.py#L367

I figured out the problem. It is a conversion from QByteArray to
bytearray. The following code causes a hang:

bytearray(self.saveState(1))

This does not:

self.saveState(1)

Attached test case.

Kovid.

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_
#!/usr/bin/env python
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai
from __future__ import (unicode_literals, division, absolute_import,
        print_function)

__license__   = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'

from PyQt4.Qt import (QMainWindow, QSplitter, QApplication, QLabel,
QWebView)

app = QApplication([])
app

class MW(QMainWindow):

def __init__(self):
QMainWindow.__init__(self)
self.s = s = QSplitter()
self.setCentralWidget(s)
self.addToolBar('test').setObjectName('one')
self.addToolBar('test2').setObjectName('two')
s.addWidget(QLabel('one'))
s.addWidget(QLabel('two'))
self.s2 = s2 = QSplitter()
s.addWidget(s2)
self.v = v = QWebView()
s2.addWidget(v)
v.page().mainFrame().setHtml('hello')

def closeEvent(self, e):
print (111, bytearray(self.saveState(1)))
e.accept()

m = MW()
m.show()
app.exec_()



signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] ANN: PyQt v4.9.2 and SIP v4.13.3 Released

2012-06-23 Thread Kovid Goyal
Just for completeness, here is the simplest possible test case:

python -c "from PyQt4.Qt import QByteArray; bytearray(QByteArray(b''))"

This causes a hang with PyQt 4.8.2 but not with PyQt 4.8.1 (sip 4.13.3)

Kovid.

On Sat, Jun 23, 2012 at 10:26:08PM +0100, Phil Thompson wrote:
> On Sat, 23 Jun 2012 21:53:48 +0530, Kovid Goyal 
> wrote:
> > On Sat, Jun 23, 2012 at 01:36:42PM +0100, Phil Thompson wrote:
> >> Hmm, hardly anything has changed in PyQt4. Can you try using the...
> >> 
> >> qpy/QtCore/qpycore_pyqtproxy.cpp
> >> 
> >> ...from 4.9.1 in 4.9.2?
> > 
> > Still hangs.
> 
> I'm struggling to think what might have changed. Do you know the line at
> which it hangs? Does it look like a deadlock?
> 
> Phil
> 
> !DSPAM:3,4fe6347418077280658049!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] ANN: PyQt v4.9.2 and SIP v4.13.3 Released

2012-06-24 Thread Kovid Goyal
On Sun, Jun 24, 2012 at 12:29:06PM +0100, Phil Thompson wrote:
> As it's a regression I'll do a brown paper bag release of 4.9.3.

Thanks, appreciate it.

Kovid.

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Small bug in checkPointer in SIP

2012-07-29 Thread Kovid Goyal
Hi Phil,

I noticed the other day that checkPointer() in siplib.c.in has

PyErr_Format(PyExc_RuntimeError, (sipWasCreated(sw) ?
"wrapped C/C++ object of %S has been deleted" :
"super-class __init__() of %S was never called"),
(PyObject *)sw);

which should have a lower case %s and you probably want something like
PyEval_GetFuncName((PyObject *)sw) or

PyObject_Repr((PyObject *)sw).

In the latter case, you'd have to check for a NULL return.

Kovid.

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Segfault with QRawFont

2012-10-19 Thread Kovid Goyal
Hi Phil,

The following snippet causes a segfault:

python -c "from PyQt4.Qt import *; app = QApplication([]); f = 
QRawFont.fromFont(QFont('Arial')); print f.familyName();  print 1"

However, if I explicitly delete the QRawFont first, the segfault goes
away:

python -c "from PyQt4.Qt import *; app = QApplication([]); f = 
QRawFont.fromFont(QFont('Arial')); print f.familyName(); del f;  print 1"

Seems to be something wrong in the object lifetime/ownership
semantics for QRawFont.

This is on linux PyQt4 4.9.4, SIP 4.14, Qt 4.8.3

I am unable to generate a backtrace at the moment as I am travelling,
let me know if you need one, and I'll try to generate it ASAP.

Kovid.


-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Segfault with QRawFont

2012-10-28 Thread Kovid Goyal
The backtrace is below. Looks to me like the QRawFont object is being
released after Qt has already released the FreeType library, leading to
the segfault. The workaround is to ensure that all QRawFont objects are
deleted before Py_Finalize() is called. I dont know if there is more
elegant way to fix this in PyQt.

#0  0x74061e3a in freeServerGlyphSet (id=39845946, this=) at text/qfontengine_x11.cpp:1146
#1  QFontEngineX11FT::freeServerGlyphSet (this=0xa922f0, id=39845946) at 
text/qfontengine_x11.cpp:1141
#2  0x74068e89 in QFontEngineFT::freeGlyphSets (this=0xa922f0) at 
text/qfontengine_ft.cpp:658
#3  0x74061ccb in QFontEngineX11FT::~QFontEngineX11FT (this=0xa922f0, 
__in_chrg=) at text/qfontengine_x11.cpp:1127
#4  0x74061d09 in QFontEngineX11FT::~QFontEngineX11FT (this=0xa922f0, 
__in_chrg=) at text/qfontengine_x11.cpp:1128
#5  0x7405f0ef in QRawFontPrivate::cleanUp (this=0xa5c290) at 
text/qrawfont.cpp:699
#6  0x7405f194 in ~QRawFontPrivate (this=0xa5c290, __in_chrg=) at text/qrawfont_p.h:94
#7  ~QExplicitlySharedDataPointer (this=, __in_chrg=) at ../../include/QtCore/../../src/corelib/tools/qshareddata.h:166
#8  ~QExplicitlySharedDataPointer (this=, __in_chrg=) at text/qrawfont.cpp:174
#9  QRawFont::~QRawFont (this=, __in_chrg=) at 
text/qrawfont.cpp:174
#10 0x74b55f46 in release_QRawFont (sipCppV=0xa087f0) at 
sipQtGuiQRawFont.cpp:936
#11 0x75208e74 in forgetObject (sw=0x7fffec9bf980) at siplib.c:10199
#12 0x75208ea9 in sipSimpleWrapper_dealloc (self=0x7fffec9bf980) at 
siplib.c:9449
#13 0x77ab7b66 in subtype_dealloc (self=0x7fffec9bf980) at 
Objects/typeobject.c:1014
#14 0x77a986f7 in insertdict (mp=0x641000, key=0x77f7d788, 
hash=13056039271, value=0x77da4b30 <_Py_NoneStruct>) at 
Objects/dictobject.c:530
#15 0x77a9abb4 in PyDict_SetItem (op=0x641000, key=0x77f7d788, 
value=0x77da4b30 <_Py_NoneStruct>) at Objects/dictobject.c:775
#16 0x77a9e5dc in _PyModule_Clear (m=) at 
Objects/moduleobject.c:138
#17 0x77b0d7bf in PyImport_Cleanup () at Python/import.c:445
#18 0x77b1a035 in Py_Finalize () at Python/pythonrun.c:454
#19 0x77b2aacc in Py_Main (argc=, argv=) 
at Modules/main.c:668
#20 0x7747760d in __libc_start_main (main=0x400970 , argc=3, 
ubp_av=0x7fffda68, init=, fini=, 
rtld_fini=, stack_end=0x7fffda58) at libc-start.c:226
#21 0x004008a9 in _start ()

Kovid.

On Fri, Oct 19, 2012 at 07:38:18PM +0530, Kovid Goyal wrote:
> Hi Phil,
> 
> The following snippet causes a segfault:
> 
> python -c "from PyQt4.Qt import *; app = QApplication([]); f = 
> QRawFont.fromFont(QFont('Arial')); print f.familyName();  print 1"
> 
> However, if I explicitly delete the QRawFont first, the segfault goes
> away:
> 
> python -c "from PyQt4.Qt import *; app = QApplication([]); f = 
> QRawFont.fromFont(QFont('Arial')); print f.familyName(); del f;  print 1"
> 
> Seems to be something wrong in the object lifetime/ownership
> semantics for QRawFont.
> 
> This is on linux PyQt4 4.9.4, SIP 4.14, Qt 4.8.3
> 
> I am unable to generate a backtrace at the moment as I am travelling,
> let me know if you need one, and I'll try to generate it ASAP.
> 
> Kovid.
> 
> 
> -- 
> _
> 
> Dr. Kovid Goyal 
> http://www.kovidgoyal.net
> http://calibre-ebook.com
> _



> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,50815eec47622150364303!


-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] another pyuic icon bug

2008-06-16 Thread Kovid Goyal
Attached is a ui file that sets different icons for various push buttons. 
However, with pyuic4 (Python User Interface Compiler 4.4.3-snapshot-20080612 
for Qt version 4.4.0) all the push buttons have the same icon. Indeed a simple 
grep on the python code generated by pyuic4 shows that only a single icon is 
referenced. The ui file works correctly in the designer preview and also worked 
correctly with pyuic4 from qt 4.3

I realize you're going to demand a simple test case, but the point here is 
that pyuic4 is breaking ui files that used to work. This is a *bad* thing as no 
one wants to go through testing 100s of old ui files. 

Here's some linux code demonstrating the bug

grep -c svg user_profile.ui 
gives 9 matches
pyuic4 user_profile.ui | grep svg 
gives 1 match

Kovid.
-- 
_____

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_



user_profiles.ui
Description: application/designer


signature.asc
Description: This is a digitally signed message part.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] another pyuic icon bug

2008-06-24 Thread Kovid Goyal
Thanks, fixed.

Kovid.

On Monday 23 June 2008 04:17:54 Phil Thompson wrote:
> On Mon, 16 Jun 2008 23:52:31 -0700, Kovid Goyal <[EMAIL PROTECTED]>
>
> wrote:
> > Attached is a ui file that sets different icons for various push buttons.
> >
> > However, with pyuic4 (Python User Interface Compiler
> > 4.4.3-snapshot-20080612
> > for Qt version 4.4.0) all the push buttons have the same icon. Indeed a
> > simple
> > grep on the python code generated by pyuic4 shows that only a single icon
> > is
> > referenced. The ui file works correctly in the designer preview and also
> > worked
> > correctly with pyuic4 from qt 4.3
> >
> > I realize you're going to demand a simple test case, but the point here
>
> is
>
> > that pyuic4 is breaking ui files that used to work. This is a *bad* thing
> > as no
> > one wants to go through testing 100s of old ui files.
> >
> > Here's some linux code demonstrating the bug
> >
> > grep -c svg user_profile.ui
> > gives 9 matches
> > pyuic4 user_profile.ui | grep svg
> > gives 1 match
> >
> > Kovid.
>
> Should be fixed in tonight's snapshot.
>
> Phil
>
>
> !DSPAM:3,485f866736311730431279!

-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_



signature.asc
Description: This is a digitally signed message part.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Advice for building PyQt4 (Qt 4.4) on Windows XP

2008-07-17 Thread Kovid Goyal
Both phonon and webkit don't compile with VS2005. You can however compile 
webkit at least with mingw. Also compile SIP and PyQt with mingw and they work 
fine with the standard python binary. 

Kovid.

On Wednesday 16 July 2008 06:34:01 Maik Tammerman wrote:
> Hello,
>
> Is it required to compile Python from sources in order to use Qt 4.4
> features? As far as I know, Qt 4.4 requires MSVC 2008 for Webkit and
> some other advanced widgets. IIRC Python extension libraries should be
> compiled with the same compiler used for building python itself. Is
> this a must? I would be glad if someone shares his/her experiences.
>
> Best regards,
> Maik
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> !DSPAM:3,487df93733962860433998!

-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_



signature.asc
Description: This is a digitally signed message part.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Wrap C++ QWidget Subclass for use in PyQt4

2008-07-29 Thread Kovid Goyal
That's because PhotoFlow tries to only load a few images (to the left and right 
of the current image) at a time. You can do the same thing in the pictureflow 
widget in calibre by sub classing  the FlowImages class which represents an 
abstract data model. Indeed, calibre uses that class to load images on demand 
from a database.

Kovid.

On Tuesday 29 July 2008 08:00:33 Tyler Distad wrote:
> On Mon, Jul 28, 2008 at 2:43 AM, kovid <[EMAIL PROTECTED]> wrote:
> > There's a wrapped version in the calibre source tree (search for calibre
> > on launchpad.net)
> >
> > Kovid.
>
> I've downloaded and used the widget from Kovid's Calibre project
> (http://launchpad.net/calibre). Unfortunately, the pictureflow widget
> wrapped in that project seems to be an older version of Ariya
> Hidayat's code. (http://code.google.com/p/pictureflow/) It's a rather
> inefficient version: Using the python-wrapped version and the
> cover_flow.py script from Calibre, loading 400 small images requires
> 342 MB of RAM.  Using Ariya's extensions to PictureFlow, that he has
> named PhotoFlow (http://code.google.com/p/photoflow/), loading that
> same directory requires only 11 MB. The actual file size of this
> directory is 13.6 MB.
>
> Because I seem utterly incapable of preparing proper SIP bindings, I
> have completely translated Ariya's PhotoFlow code to Python. The only
> piece I am lacking is a Python-wrapped version of the latest version
> of pictureflow from http://code.google.com/p/pictureflow. However, I
> cannot seem to bind his code no matter what I try. I believe my SIP
> binding is written correctly and have attached it to this email, but
> there seems to be something else wrong in either my configure.py or in
> the readiness of the pictureflow code for binding.
>
> If anyone can offer help or advice on how to bind the pictureflow
> widget, I would be immensely grateful.
>
> Tyler Distad
>
> Both files I have attached are modified versions of Kovid's from the
> Calibre source.
>
>
> !DSPAM:3,488f30a033969229514251!

-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_



signature.asc
Description: This is a digitally signed message part.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] display a widget in a QTableView

2008-10-16 Thread Kovid Goyal
class ProgressBarDelegate(QAbstractItemDelegate):

def sizeHint(self, option, index):
return QSize(120, 30)

def paint(self, painter, option, index):
opts = QStyleOptionProgressBarV2()
opts.rect = option.rect
opts.minimum = 1
opts.maximum = 100
opts.textVisible = True
percent, ok = index.model().data(index, Qt.DisplayRole).toInt()
if not ok:
percent = 0
opts.progress = percent
opts.text = QString(_('Unavailable') if percent == 0 else 
'%d%%'%percent)
QApplication.style().drawControl(QStyle.CE_ProgressBar, opts, painter)

On Thursday 16 October 2008 09:50:54 Wim Verhavert wrote:
> Dear all,
>
> I want to do something in PyQT I have seen many times in other
> applications: A QTableView where the last column contains a QProgressbar.
> Basically I want to implement some kind of cue where each item is processed
> which can take a while. To give some visual feedback I want to display
> a progressbar in the last column. This would allow sorting on progress
> and such.
> I have the book 'Rapid GUI Programming with Python and Qt' by Mark
> Summerfield at hand which contains a section about custom delegates. I
> have done similar things in the past, but somehow I'm not able to
> translate this into the thing I want to do. Is there somebody out
> there that could give me a head start?
>
> I think it will need to create a custom delegate and override the
> paint method. But how? How do I paint a progressbar? Do I have to do
> this from scratch, i.e. filling a part of the cell with a color, or
> can I use a QProgressbar? Any suggestions are welcome.
>
> Cheers!
>
> Wim
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> !DSPAM:3,48f771b131535171880063!

-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_



signature.asc
Description: This is a digitally signed message part.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] i18n

2009-02-11 Thread Kovid Goyal
Ditch the whole Qt translation infrastructure. Simply postprocess the output 
of pyuic4 to replace the calls to QtCore.QCoreApplication.translate() with _()

Then you can use gettext and the nice translation infrastructure in launchpad. 
This has the additional advantage of not tying in your translation 
infrastructure to a graphical toolkit.

Kovid.

On Wednesday 11 February 2009 06:57:59 Frédéric wrote:
> Does anybody could point me on example how to use i18n in PyQt?
>
> Riverbank documentation says that one should not use tr() method, but
> insteead QtCore.QCoreApplication.translate(). As the object must be
> passed to this method, this not improves the readability :o/
>
> Are there some tips, for example, to bind the _() method I use with
> gettext and PyGTK? Something to help me migrate my code without having
> to modify it everywhere...
>
> Are there also some tools to migrate a .po file to a Qt i18n stuff?
>
> Thanks,
>
> --
>Frédéric
>
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> !DSPAM:3,4992e80175721139086412!

-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : ko...@theory.caltech.edu
web   : http://www.kovidgoyal.net
_


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


Re: [PyQt] i18n

2009-02-11 Thread Kovid Goyal
On Wednesday 11 February 2009 12:06:13 Doug Bell wrote:
> I like that idea in general, but how do you deal with translations of
> strings that are internal to Qt (in file dialogs, etc.)?

Qt provides .mo files with translations of all the internal strings. Just add 
them to your app in your build script. 

-- 
Kovid Goyal
www.kovidgoyal.net
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] i18n

2009-02-11 Thread Kovid Goyal
On Wednesday 11 February 2009 12:05:13 you wrote:
> On 2/11/2009 8:14 PM, Kovid Goyal wrote:
> You'll be hard-pressed to find a Windows translation program better than
> Linguist. Do you have any suggestion? Did you personally evaluate
> Linguist and are aware of its features?
>
> (OK, Linguist can now import .po files too, but then I don't see the
> point of using an external translation package).

The critical thing in open source projects is to make it as easy as possible 
for volunteers to contribute translations. Launchpad allows you to have a 
simple web based interface where they can contribute translated strings 
easily. Plus it suggests translations for frequently used strings across its 
entire database of available translations. 

>
> Plus I'm not sure gettext has the advanced plural support (does it?).
>


http://www.gnu.org/software/automake/manual/gettext/Plural-forms.html


> > This has the additional advantage of not tying in your translation
> > infrastructure to a graphical toolkit.
>
> Given how simple is to batch-substitute tr() to _() (so simple that
> you're even suggesting it yourself), I don't really see a point here.
> Converting the whole application to another toolkit would probably be
> much harder in the first place.

What if your application has many parts, only some of which need a graphical 
toolkit. What if you want to write different GUIs for different contexts? 

Kovid.

-- 
Kovid Goyal
www.kovidgoyal.net
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] i18n

2009-02-11 Thread Kovid Goyal
On Wednesday 11 February 2009 14:58:16 Giovanni Bajo wrote:
> On mer, 2009-02-11 at 12:32 -0800, Kovid Goyal wrote:
> > On Wednesday 11 February 2009 12:05:13 you wrote:
> > > On 2/11/2009 8:14 PM, Kovid Goyal wrote:
> > > You'll be hard-pressed to find a Windows translation program better
> > > than Linguist. Do you have any suggestion? Did you personally evaluate
> > > Linguist and are aware of its features?
> > >
> > > (OK, Linguist can now import .po files too, but then I don't see the
> > > point of using an external translation package).
> >
> > The critical thing in open source projects is to make it as easy as
> > possible for volunteers to contribute translations. Launchpad allows you
> > to have a simple web based interface where they can contribute translated
> > strings easily. Plus it suggests translations for frequently used strings
> > across its entire database of available translations.
>
> Sure, but "open-source" doesn't say it all. I appreciate Launchpad very
> much, but in a business environment translations are carried on by
> professionals, so it's less important to manage 200 volunteers
> translating a couple of sentence each one at random times.
>

The OP was asking (as far as I can tell) about an open source project. And 
have you looked at lokalize recently?

> I'm not saying that your suggestion of using gettext is totally wrong:
> it's surely an option to consider. But there are advantages in the Qt
> translation toolchain too.
>
> > > Plus I'm not sure gettext has the advanced plural support (does it?).
> >
> > http://www.gnu.org/software/automake/manual/gettext/Plural-forms.html
>
> Thanks for the pointer.
>
> > > > This has the additional advantage of not tying in your translation
> > > > infrastructure to a graphical toolkit.
> > >
> > > Given how simple is to batch-substitute tr() to _() (so simple that
> > > you're even suggesting it yourself), I don't really see a point here.
> > > Converting the whole application to another toolkit would probably be
> > > much harder in the first place.
> >
> > What if your application has many parts, only some of which need a
> > graphical toolkit.
>
> Yes, this can be an issue. It's less problematic in C++, where you'd die
> for using QtCore everywhere you're allowed too anyway and thus have the
> translation functions available, but Python doesn't need it (mostly).
>
> I usually put workarounds in place to be able to use Qt's translation in
> the Qt-agnostic packages within a Qt-based application, but I agree that
> it is somewhat a problem.
>
> > What if you want to write different GUIs for different contexts?
>
> Different GUI with the same texts and thus reusing the same translation?
> Do you happen to know a single open source project that does this?

Two different GUIs wont share all strings, but they will have lots of strings 
in common. It would be silly to have the same strings being translated in two 
translation frameworks. And for an example look at calibre, which has both a 
GUI and a CLI and all strings are translated using gettext (a number of 
strings are common to both the GUI and the CLI).

Kovid.

-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : ko...@theory.caltech.edu
web   : http://www.kovidgoyal.net
_

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


Re: [PyQt] i18n

2009-02-11 Thread Kovid Goyal
On Wednesday 11 February 2009 17:41:46 Doug Bell wrote:
> Kovid Goyal wrote:
> > On Wednesday 11 February 2009 12:06:13 Doug Bell wrote:
> > > I like that idea in general, but how do you deal with translations of
> > > strings that are internal to Qt (in file dialogs, etc.)?
> >
> > Qt provides .mo files with translations of all the internal strings. Just
> > add them to your app in your build script.
>
> Am I missing something here?  I can see how that would get the Qt
> internal strings into the gettext translation files, but how do you get
> Qt's file dialog to use the gettext translation function rather than the
> Qt one?

You activate the file for the Qt translation system as well as the python 
translation system. 

Kovid.

-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : ko...@theory.caltech.edu
web   : http://www.kovidgoyal.net
_

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


Re: [PyQt] Any Large PyQt Projects?

2009-02-19 Thread Kovid Goyal
I'm the lead developer of calibre (http://calibre.kovidgoyal.net) which is 
~120k lines of python + another few thousand lines of C code.

I've found in general that you can quite easily use multi-processing instead of
multi-threading to get around the global interpreter lock (this assumes that 
your 
algorithms dont require lots of data passing). For performance/os
interface sections of the code, it's easy enough to write C modules to do the
neccessary work. It occassionally becomes neccessary to drop down to C for high
performance parts of the GUI as well, though i can't comment on OpenGL.

Basically, python will work very well for about 90-95% of what you need to do,
for the rest, write C modules. Interfacing Python and C is trivial.

Kovid.


On Thu, Feb 19, 2009 at 02:33:57PM -0800, Brent Villalobos wrote:
> I'm looking for examples from people who have written large PyQt 
> applications and I would like to hear your opinions on what worked well 
> and what did not specifically with choosing python over C/C++.  In 
> particular, how does your python application handle tasks that require a 
> lot of computation?  How does it handle multiple thread performance 
> given python's limitations on only running on one CPU (global 
> interpreter lock)?  I don't need too much detail (obviously nothing 
> proprietary), but I just want to know if anyone has any "red flags" that 
> people should be aware of before writing a large python gui app with 
> things like openGL contexts and heavy mathematical computation?
> 
> Let's make this interesting and see who has written the largest PyQt 
> application.  How many lines of code are we talking about?  10,000?  
> 100,000? 1,000,000???
> -Brent
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,499ddeb575724022331274!
> 
> 

-- 
_

Kovid Goyal 
http://www.kovidgoyal.net
http://calibre.kovidgoyal.net
_


pgp2jCp988cFP.pgp
Description: PGP signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Next Releases

2009-05-26 Thread Kovid Goyal
pyuic4 doesn't have support for the QWizardPage class, as demonstrated by the
attached .ui file.

Kovid.

On Tue, May 26, 2009 at 09:21:38AM +0100, Phil Thompson wrote:
> I plan to release new versions of SIP, PyQt3, PyQt4 and QScintilla at the
> end of the week based on the current snapshots.
> 
> If there is something you think is missing or broken then now would be a
> good time to remind me.
> 
> Phil
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4a1ba74813131347477031!
> 
> 

-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre.kovidgoyal.net
_


 WizardPage
 
  
   
0
0
400
300
   
  
  
   Welcome to calibre
  
  
   
:/images/wizard.svg:/images/wizard.svg
  
  
   Welcome to calibre
  
  
   The one stop solution to all your e-book needs.
  
  
   

 
  Choose your e-book reader. This will set the conversion options 
to produce e-books optimized for your device.
 
 
  true
 

   
   

 
  &Manufacturers
 
 
  
   
  
 

   
   

 
  &Devices
 
 
  
   
  
 

   
  
 
 
  
 
 



pgphr5VVr1fcX.pgp
Description: PGP signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Is this possible using pyqt?

2009-09-08 Thread Kovid Goyal
Use python-mechanize.

Kovid.

On Mon, Sep 07, 2009 at 12:30:22PM +0100, jim biri wrote:
> Hi,
> Wonder if anyone can help.
> I'm looking to build a simple command line appln that logs into a website
> (following redirects, using SSL), and clicks on a download link to download
> some files. Nothing fishy here, just looking to automate a mundane and
> manual process.
> Is this possible using pyqt? If so, any pointers as to which
> examples/tutorials might be particularly useful?
> I've found "/python-qt4-doc/examples/network/http.py", but any others?
> And ... is what I'm trying to do actually doable using pyqt?
> Thanks for any help,
> JB
> 
> 
> !DSPAM:3,4aa4ef6129656418799522!

> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4aa4ef6129656418799522!


-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre.kovidgoyal.net
_


pgpYNcxelkkHU.pgp
Description: PGP signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyQt] Segfault in PyQt 4.6.1

2009-10-29 Thread Kovid Goyal
There appears to be a segfault when constructing the QWebPage object in PyQt
4.6.1 (regression for 4.5.x)

Here's a one liner to reproduce it

python2.6 -c "from PyQt4.Qt import QApplication; QApplication([]); from 
PyQt4.QtWebKit import QWebPage; QWebPage()"

When run in gdb, the segfault does not happen, so I cannot get a stack trace. 

This is on 

Linux giskard 2.6.31-gentoo-r4 #1 SMP Tue Oct 27 16:11:20 MDT 2009 x86_64 
Intel(R) Core(TM) i7 CPU 940 @ 2.93GHz GenuineIntel GNU/Linux

Kovid.
-- 
_____

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre.kovidgoyal.net
_


pgpcpb0xzc8Op.pgp
Description: PGP signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Segfault in PyQt 4.6.1

2009-10-29 Thread Kovid Goyal
I should add that the segfault is present in the current snapshot as well:

python2.6 -c "from PyQt4.Qt import QApplication, PYQT_VERSION_STR; 
QApplication([]); print PYQT_VERSION_STR; from PyQt4.QtWebKit import QWebPage; 
QWebPage()"

4.7-snapshot-20091028
Segmentation fault

Kovid.

On Thu, Oct 29, 2009 at 11:22:35AM -0600, Kovid Goyal wrote:
> There appears to be a segfault when constructing the QWebPage object in PyQt
> 4.6.1 (regression for 4.5.x)
> 
> Here's a one liner to reproduce it
> 
> python2.6 -c "from PyQt4.Qt import QApplication; QApplication([]); from 
> PyQt4.QtWebKit import QWebPage; QWebPage()"
> 
> When run in gdb, the segfault does not happen, so I cannot get a stack trace. 
> 
> This is on 
> 
> Linux giskard 2.6.31-gentoo-r4 #1 SMP Tue Oct 27 16:11:20 MDT 2009 x86_64 
> Intel(R) Core(TM) i7 CPU 940 @ 2.93GHz GenuineIntel GNU/Linux
> 
> Kovid.
> -- 
> _
> 
> Dr. Kovid Goyal 
> http://www.kovidgoyal.net
> http://calibre.kovidgoyal.net
> _



> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,4ae9cff529653317716138!


-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre.kovidgoyal.net
_


pgpM3xxwtmDpw.pgp
Description: PGP signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[PyKDE] no module uic in binary win32 package?

2007-01-08 Thread Kovid Goyal
Hi,

Is it possible to have the module uic included in the PyQt4 binary package for 
windows. I have code that depends on it.

Thanks,

Kovid.
-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] PyQt dbus doesn't work with HAL

2007-01-10 Thread Kovid Goyal
Hi,

I've been testing dbus.mainloop.qt with HAL. With the glib mainloop my code 
receives HAL signals, with the Qt mainloop it does not. THis is with 
dbus-pythun-0.80rc3 and the latest PyQt4 snapshot.

Here's the test code
import dbus, sys
import dbus.mainloop.qt
from PyQt4.Qt import QApplication

def handle_signal(*args):
  print 'received signal:', args

dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True)
bus = dbus.SystemBus()
bus.add_signal_receiver(handle_signal, None, None, None)

app = QApplication(sys.argv)
app.exec_()


The output I get is
QSocketNotifier: Can only be used with threads started with QThread
QSocketNotifier: Can only be used with threads started with QThread
received signal: (dbus.String(u':1.32'),)

But plugging in a USB device doesn't generate a signal. The same code with the 
glib mainloop does receive a signal.

Kovid.
-- 
_____

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] PyQt dbus doesn't work with HAL

2007-01-11 Thread Kovid Goyal
Nice catch. It works if I create the QApplication before the mainloop. There 
are also no warnings from QSocketNotifier.

Thanks,

Kovid.

On Thursday 11 January 2007 01:01, Phil Thompson wrote:
> On Thursday 11 January 2007 4:28 am, Kovid Goyal wrote:
> > Hi,
> >
> > I've been testing dbus.mainloop.qt with HAL. With the glib mainloop my
> > code receives HAL signals, with the Qt mainloop it does not. THis is with
> > dbus-pythun-0.80rc3 and the latest PyQt4 snapshot.
> >
> > Here's the test code
> > import dbus, sys
> > import dbus.mainloop.qt
> > from PyQt4.Qt import QApplication
> >
> > def handle_signal(*args):
> >   print 'received signal:', args
> >
> > dbus.mainloop.qt.DBusQtMainLoop(set_as_default=True)
> > bus = dbus.SystemBus()
> > bus.add_signal_receiver(handle_signal, None, None, None)
> >
> > app = QApplication(sys.argv)
> > app.exec_()
> >
> >
> > The output I get is
> > QSocketNotifier: Can only be used with threads started with QThread
> > QSocketNotifier: Can only be used with threads started with QThread
> > received signal: (dbus.String(u':1.32'),)
> >
> > But plugging in a USB device doesn't generate a signal. The same code
> > with the glib mainloop does receive a signal.
>
> Is there any difference if you create the QApplication before the mainloop?
>
> Phil
>
> _______
> PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
> !DSPAM:2,45a5fd8a24221328276924!

-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] (no subject)

2007-01-30 Thread Kovid Goyal

Hi,

Calling a particular method using dcopext yields a different result from
calling it using the dcop commandline client. Here's a test script that calls
the method (requires ktorrent)

from kdecore import KApplication
import dcopext, sys, subprocess

app = KApplication(sys.argv, 'test')
dcop = app.dcopClient()
kt = dcopext.DCOPApp('ktorrent', dcop).KTorrent
print kt.maxUploadRate()
print kt.getTorrentNumbers(3)
subprocess.call('dcop ktorrent KTorrent getTorrentNumbers 3', shell=True)

The call to getTorrentNumbers produces a (True, None) when called via dcopext
and a list of the torrent numbers when called via the command line client.

Using kde 3.5.6. Other method calls on ktorrent work as shown by the call to
maxUploadRate.

Thanks,

Kovid.

_____

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] DCOP memory leak

2007-01-31 Thread Kovid Goyal
Does this help:
from dcopext import DCOPClient, DCOPApp
dcop=DCOPClient()
dcop.attach()

player = DCOPApp ("amarok", dcop).player
while 1:
  print player.trackCurrentTimeMs()

Kovid.
On Wednesday 31 January 2007 12:17:42 Tim De Graeve wrote:
> Hi,
>
> I'm writing a script for Amarok in python that has to do a lot of DCOP
> calls in a short amount of time.
> Now, I have noticed that every time I do a DCOP call my program grows in
> memory usage, the short program below demonstrates this:
>
> from dcopext import DCOPClient, DCOPApp
>
> dcop=DCOPClient()
> 
>
> while 1:
> AmarokDcopRes = DCOPApp ("amarok", dcop)
> ok, ms = AmarokDcopRes.player.trackCurrentTimeMs()
> print ms
>
>
> Note that in the program I'm writing the while loop is replaced by a
> timer event.
> I also noticed that the program only grows in memory use once the 'ok,
> ms = AmarokDcopRes.player.trackCurrentTimeMs()' code is executed.
>
> I already posted my problem on the comp.lang.python Usenet-group and
> someone suggested to post here because my problem seems more to be pyKDE
> and DCOP related.
> Does someone have any suggestions on how I can avoid this memory leak?
>
> Kind regards,
>
> Tim
>
> ___
> PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
> http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
> !DSPAM:2,45c0fac944256935130580!



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyKDE] mysterious dcopext bug

2007-02-02 Thread Kovid Goyal
Hi,

Calling a particular method using dcopext yields a different result from
calling it using the dcop commandline client. Here's a test script that calls
the method (requires ktorrent)

from kdecore import KApplication
import dcopext, sys, subprocess

app = KApplication(sys.argv, 'test')
dcop = app.dcopClient()
kt = dcopext.DCOPApp('ktorrent', dcop).KTorrent
print kt.maxUploadRate()
print kt.getTorrentNumbers(3)
subprocess.call('dcop ktorrent KTorrent getTorrentNumbers 3', shell=True)

The call to getTorrentNumbers produces a (True, None) when called via dcopext.
However when called via the commandline client it produces a list of torrent 
numbers as expected. 

Using kde 3.5.6. Other method calls on ktorrent work as shown by the call to
maxUploadRate.

Thanks,

Kovid.
-- 
_____

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


Re: [PyKDE] mysterious dcopext bug

2007-02-03 Thread Kovid Goyal
I figured out that this happens because the method getTorrentNumbers returns a 
QValueList. Does anyone know how I can unmarshall that? dcop_next 
doesn't seem to work.

b = QByteArray()
s = QDataStream (b, IO_WriteOnly)
dcop_add(s, 1, 'int')
ok, rtype, arr =  dcop.call('ktorrent', 'KTorrent', 'getTorrentNumbers(int)', 
b)
s = QDataStream(arr, IO_ReadOnly)
print dcop_next(s, rtype)

gives None. I've verified that there are bytes in arr by read rawbytes from s.

Thanks,

Kovid

On Friday 02 February 2007 10:42:52 Kovid Goyal wrote:
> Hi,
>
> Calling a particular method using dcopext yields a different result from
> calling it using the dcop commandline client. Here's a test script that
> calls the method (requires ktorrent)
>
> from kdecore import KApplication
> import dcopext, sys, subprocess
>
> app = KApplication(sys.argv, 'test')
> dcop = app.dcopClient()
> kt = dcopext.DCOPApp('ktorrent', dcop).KTorrent
> print kt.maxUploadRate()
> print kt.getTorrentNumbers(3)
> subprocess.call('dcop ktorrent KTorrent getTorrentNumbers 3', shell=True)
>
> The call to getTorrentNumbers produces a (True, None) when called via
> dcopext. However when called via the commandline client it produces a list
> of torrent numbers as expected.
>
> Using kde 3.5.6. Other method calls on ktorrent work as shown by the call
> to maxUploadRate.
>
> Thanks,
>
> Kovid.



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_

___
PyKDE mailing listPyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde


[PyQt] OSX and threads

2007-06-09 Thread Kovid Goyal
Hi,

The following test code gives me an error on OSX but not on either windows or 
linux:
from PyQt4.Qt import *
import sys
class test(QObject):
  def __init__(self, window):
QObject.__init__(self)
self.window = window
self.startTimer(1000)
window.show()

app = QApplication(sys.argv)
window = QMainWindow()
test(window)
app.exec_()

The error is:
QObject::startTimer: QTimer can only be used with threads started with QThread

What am I doing wrong?

Thanks,

Kovid.
-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] OSX and threads

2007-06-09 Thread Kovid Goyal
Think I sent my previous reply only to Phil. 
Changing to a=test(window) doesn't help.
I'm using PyQt 20070606 with Qt 4.3.0 on OSX 10.4.8.
sip is compiled with the -n option and PyQt with -e QtCore -e QtScg -e QtGui.
Qt is compiled with -static -universal -no-nis -fast 

Thanks,

Kovid.

On Saturday 09 June 2007 16:11:57 Phil Thompson wrote:
> On Saturday 09 June 2007 11:35 pm, Kovid Goyal wrote:
> > Hi,
> >
> > The following test code gives me an error on OSX but not on either
> > windows or linux:
> > from PyQt4.Qt import *
> > import sys
> > class test(QObject):
> >   def __init__(self, window):
> > QObject.__init__(self)
> > self.window = window
> > self.startTimer(1000)
> > window.show()
> >
> > app = QApplication(sys.argv)
> > window = QMainWindow()
> > test(window)
> > app.exec_()
> >
> > The error is:
> > QObject::startTimer: QTimer can only be used with threads started with
> > QThread
> >
> > What am I doing wrong?
>
> Not keeping a reference to the test instance?
>
> Phil
>
> !DSPAM:2,466b342e160002104433144!



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] OSX and threads

2007-06-10 Thread Kovid Goyal
So I cannot create a Universal binary for distribution of my PyQt based app? 
That's something of a blow. Is there an estimate on when you expect support 
to be completed? Is there anything I can do to help? 

It did compile fine, but no non-trivial code runs on it. That test case was 
just one error I see. 

Thanks,

Kovid.

>
> sip's -n option isn't fully implemented yet - I'm surprised the code
> compiles.
>
> The script runs fine for me with normal builds.
>
> Phil


-- 
_____

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] OSX and threads

2007-06-10 Thread Kovid Goyal
Hmm then it must be something else in my environment. I'm now with fewer 
non-default flags, unfortunately I only have an old and slow G3 to test on, 
it takes 12 hrs to compile Qt. 

Do you have any suggestions on what sort of thing could be causing this? It 
would be immensely helpful if I didn't have to recompile everything more than 
once.

Thanks,

Kovid.

On Sunday 10 June 2007 08:18:41 Phil Thompson wrote:
> On Sunday 10 June 2007 3:55 pm, Kovid Goyal wrote:
> > So I cannot create a Universal binary for distribution of my PyQt based
> > app? That's something of a blow. Is there an estimate on when you expect
> > support to be completed? Is there anything I can do to help?
> >
> > It did compile fine, but no non-trivial code runs on it. That test case
> > was just one error I see.
> >
> > Thanks,
> >
> > Kovid.
> >
> > > sip's -n option isn't fully implemented yet - I'm surprised the code
> > > compiles.
> > >
> > > The script runs fine for me with normal builds.
> > >
> > > Phil
>
> Sorry, my mistake. I was referring to sip's -n flag, you were referring to
> sip's configure.py's -n flag.
>
> Phil
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> !DSPAM:2,466c16ed289661902568488!



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] OSX and threads

2007-06-10 Thread Kovid Goyal
It's the call to self.startTimer(1000)

Kovid.

On Sunday 10 June 2007 09:38:53 Phil Thompson wrote:
> On Sunday 10 June 2007 5:17 pm, Kovid Goyal wrote:
> > Hmm then it must be something else in my environment. I'm now with fewer
> > non-default flags, unfortunately I only have an old and slow G3 to test
> > on, it takes 12 hrs to compile Qt.
> >
> > Do you have any suggestions on what sort of thing could be causing this?
> > It would be immensely helpful if I didn't have to recompile everything
> > more than once.
> >
> > Thanks,
> >
> > Kovid.
> >
> > On Sunday 10 June 2007 08:18:41 Phil Thompson wrote:
> > > On Sunday 10 June 2007 3:55 pm, Kovid Goyal wrote:
> > > > So I cannot create a Universal binary for distribution of my PyQt
> > > > based app? That's something of a blow. Is there an estimate on when
> > > > you expect support to be completed? Is there anything I can do to
> > > > help?
> > > >
> > > > It did compile fine, but no non-trivial code runs on it. That test
> > > > case was just one error I see.
> > > >
> > > > Thanks,
> > > >
> > > > Kovid.
> > > >
> > > > > sip's -n option isn't fully implemented yet - I'm surprised the
> > > > > code compiles.
> > > > >
> > > > > The script runs fine for me with normal builds.
> > > > >
> > > > > Phil
> > >
> > > Sorry, my mistake. I was referring to sip's -n flag, you were referring
> > > to sip's configure.py's -n flag.
> > >
> > > Phil
> > > ___
> > > PyQt mailing listPyQt@riverbankcomputing.com
> > > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> Exactly when is the message displayed? Is it before the first line of your
> script is executed?
>
> I'd suspect the problem is your static Qt build - that's probably the
> biggest difference to mine.
>
> Phil
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> !DSPAM:2,466c29c4289665294633035!



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] OSX and threads

2007-06-11 Thread Kovid Goyal
It was indeed the static build. Thanks.

Kovid.

On Sunday 10 June 2007 09:38:53 Phil Thompson wrote:
> On Sunday 10 June 2007 5:17 pm, Kovid Goyal wrote:
> > Hmm then it must be something else in my environment. I'm now with fewer
> > non-default flags, unfortunately I only have an old and slow G3 to test
> > on, it takes 12 hrs to compile Qt.
> >
> > Do you have any suggestions on what sort of thing could be causing this?
> > It would be immensely helpful if I didn't have to recompile everything
> > more than once.
> >
> > Thanks,
> >
> > Kovid.
> >
> > On Sunday 10 June 2007 08:18:41 Phil Thompson wrote:
> > > On Sunday 10 June 2007 3:55 pm, Kovid Goyal wrote:
> > > > So I cannot create a Universal binary for distribution of my PyQt
> > > > based app? That's something of a blow. Is there an estimate on when
> > > > you expect support to be completed? Is there anything I can do to
> > > > help?
> > > >
> > > > It did compile fine, but no non-trivial code runs on it. That test
> > > > case was just one error I see.
> > > >
> > > > Thanks,
> > > >
> > > > Kovid.
> > > >
> > > > > sip's -n option isn't fully implemented yet - I'm surprised the
> > > > > code compiles.
> > > > >
> > > > > The script runs fine for me with normal builds.
> > > > >
> > > > > Phil
> > >
> > > Sorry, my mistake. I was referring to sip's -n flag, you were referring
> > > to sip's configure.py's -n flag.
> > >
> > > Phil
> > > ___
> > > PyQt mailing listPyQt@riverbankcomputing.com
> > > http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> Exactly when is the message displayed? Is it before the first line of your
> script is executed?
>
> I'd suspect the problem is your static Qt build - that's probably the
> biggest difference to mine.
>
> Phil
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> !DSPAM:2,466c29c4289665294633035!



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] PyQT Universal Binary - MAC Intel & PPC

2007-06-13 Thread Kovid Goyal
You need to ensure that Qt, sip, PyQt and any additional dependencies are all 
compiled as universal binaries. 

Kovid.

On Wednesday 13 June 2007 08:29:54 Anita Diliberto wrote:
> I have created a PyQt application using Qt4.1.1 and PyQt4 and Python2.4
> on a MAC Intel.  I am using py2app to create an executable.  I can run the
> executable on the Mac Intel, but I can't seem to run it on the MAC PowerPC.
> Any suggestions on how I would do this?
>
> Thanks - Anita
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> !DSPAM:2,46700db7187168330580563!



-- 
_____

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] pyuic vs. uic.loadUi()?

2007-06-15 Thread Kovid Goyal
Just write a Makefile to help you during development. I really don't think 
it's worth burdening your users with the extra load time. Also if you plan on 
going multi-platform, you will have to write platform specific hacks to 
figure out the loaction of the ui files.

Kovid.

Kovid.

On Friday 15 June 2007 08:34:19 Dirk Reiners wrote:
>   Hi Everybody,
>
> as I said already I'm just starting out using PyQt and therefore I would
> like to tap into the experience pool on the list to avoid making
> fundamental mistakes early in the project that are hard to fix later.
>
> I'm trying to decide whether to a) use pyuic4 to generate a python module
> to include, or b) use uic.loadUi() to load the .ui file directly.
>
> As far as I can see the only possible disadvantage of b) is the time it may
> take to create the ui compared to just loading the .pyc file. The advantage
> is not having to remember to run the build system (scons in my case, thanks
> to Patrick Hartling for the pyuic builder!). A difference (neutral) is not
> being able to derive from the module and avoid having to add .ui to access
> the ui variables, but that doesn't look like a big deal.
>
> Is there something more that I'm missing?
>
> Thanks
>
>   Dirk
>
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> !DSPAM:2,4672b21b235121694714482!



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] pyuic vs. uic.loadUi()?

2007-06-15 Thread Kovid Goyal
Yeah If you're application can be distributed as an egg and you're willing to 
make your windows users install python, setuptools, Qt and PyQt. And your 
application doesn't depend on any other third party libraries that may not be 
easily available on all platforms. 

In short for anything but the simplest of applications, eggs don't work for 
cross platform development. They do however work very well if your sticking 
to linux.  

Kovid.

On Friday 15 June 2007 10:00:49 Andreas Pakulat wrote:
> On 15.06.07 09:35:34, Kovid Goyal wrote:
> > Just write a Makefile to help you during development. I really don't
> > think it's worth burdening your users with the extra load time.
>
> Hmm, I haven't really experienced that much delay in load time. Also
> this largely depends on the type of application. An application that
> opens a lot of new windows frequently, or is itself started/exited
> frequently suffers much more from this than one that only has a
> mainwindow and maybe another dialog or two or is only started once per
> day.
>
> > Also if you plan on
> > going multi-platform, you will have to write platform specific hacks to
> > figure out the loaction of the ui files.
>
> Thats completely wrong. In fact there are quite good python ways of
> storing the .ui file in an egg and using it from there. Been there, done
> that, worked out nicely.
>
> Andreas



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

home  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Deploying PyQt4 application

2008-01-26 Thread Kovid Goyal
You need to subclass py2app and use otool -L and install_name_tool to rename 
the framework dependencies. See for example:
https://libprs500.kovidgoyal.net/browser/trunk/osx_installer.py
http://doc.trolltech.com/qq/qq09-mac-deployment.html

Kovid.

On Friday 25 January 2008 15:10:57 Rémy HUBSCHER wrote:
> Hello,
>
> As I told you, I need to deploy my PyQt4 application on Windows and
> Mac OS X.
> I worked with Py2Exe using this Tutorial :
> http://py2exe.org/index.cgi/Py2exeAndPyQt
>
> For Py2App, everything seams to work, but, PyQt4 is not looking for
> the Qt4 framework in the bundle.
> How can I change that ?
>
> I someone who deployed a PyQt4 application on Mac OS X and who could
> help me please ?
>
> Thanks
>
> Natim
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>
> !DSPAM:3,479a6ceb257791152110182!



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_

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


Re: [PyQt] pyuic4 doesn't handle qlistwidgets

2008-05-24 Thread Kovid Goyal
I pointed out exactly where the problem in the code is. The first 5 lines of 
retranslateUI(). I don't have the time to mess around creating a minimal ui 
file that reproduces the problem. The ui file I attached worked in 4.3.x and 
not in 4.4.2, which indicates a bug in pyuic4 from 4.4.2

Kovid.

On Saturday 24 May 2008 12:42:18 Andreas Pakulat wrote:
> On 24.05.08 10:54:32, Kovid Goyal wrote:
> > Hi Phil,
> >
> > Another pyuic4 (Python User Interface Compiler 4.4.2 for Qt version
> > 4.4.0) bug. It generates invalid .py files from .ui files that contain
> > qlistwidgets with icons. See attached example. In particular, the code in
> > retranslateUI is broken as the local variable icon is not defined.
>
> I hope you don't expect anybody to read through all that code to find
> the actual problem ;) I suggest to create a much smaller sample, for
> example just having a single QListWidget with just one item in it that
> has a pixmap set.
>
> Andreas



-- 
_

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_


signature.asc
Description: This is a digitally signed message part.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] pyuic4 doesn't handle qlistwidgets

2008-06-02 Thread Kovid Goyal
Well, I found the time to generate a simple test case (using today's snapshot 
of PyQt4). The .ui file is attached. Running pyuic4 on it produces the  
erroneous code. In particular, the icon for the list widget is a local 
variable initialized in the setupUI function, but used in the retranslateUI 
function. Thus when retranslateUI is called it raises an exception.

Hope that clears it up for you.

Kovid.

On Saturday 24 May 2008 12:42:18 Andreas Pakulat wrote:
>
> I hope you don't expect anybody to read through all that code to find
> the actual problem ;) I suggest to create a much smaller sample, for
> example just having a single QListWidget with just one item in it that
> has a pixmap set.
>
> Andreas



-- 
_____

Kovid Goyal  MC 452-48
California Institute of Technology
1200 E California Blvd
Pasadena, CA 91125

cell  : +01 626 390 8699
office: +01 626 395 6595 (449 Lauritsen)
email : [EMAIL PROTECTED]
web   : http://www.kovidgoyal.net
_


test.py
Description: application/python


test.ui
Description: application/designer


signature.asc
Description: This is a digitally signed message part.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Segfault with QRawFont

2012-10-28 Thread Kovid Goyal
Blanket not calling dtors would be problematic, there's no way to be
sure what side effects that would have. One solution would be to
specialize the dealloc function for QRawFont objects to check if the
application is exiting and abort. 

Another might be to register a cleanup function using the atexit module
that calls deletes all QRawFont objects (at least their underlying C++
objects), though since atexit is
called from Py_Finalize() that would only work if Qt hasn't released
FreeType at that time.

Kovid.

On Sun, Oct 28, 2012 at 01:17:05PM +, Phil Thompson wrote:
> On Sun, 28 Oct 2012 15:38:59 +0530, Kovid Goyal 
> wrote:
> > The backtrace is below. Looks to me like the QRawFont object is being
> > released after Qt has already released the FreeType library, leading to
> > the segfault. The workaround is to ensure that all QRawFont objects are
> > deleted before Py_Finalize() is called. I dont know if there is more
> > elegant way to fix this in PyQt.
> 
> The best solution at the moment is to explicitly del problematic objects
> when the application terminates.
> 
> PyQt does have a mechanism for doing this automatically but only for
> QObjects and it has to be explicitly coded.
> 
> At the moment SIP disables the calling of any Python reimplementations of
> virtuals when an application exits. I could extend this to disable any
> calls to C++ dtors when Python objects get garbage collected. This would be
> optional and enabled by function implemented in the sip module. It would be
> disabled by default (to reflect the current behaviour) as I'm not sure if
> it might break current applications.
> 
> Thoughts?
> 
> Phil
> 
> > #0  0x74061e3a in freeServerGlyphSet (id=39845946,
> this= > out>) at text/qfontengine_x11.cpp:1146
> > #1  QFontEngineX11FT::freeServerGlyphSet (this=0xa922f0, id=39845946) at
> > text/qfontengine_x11.cpp:1141
> > #2  0x74068e89 in QFontEngineFT::freeGlyphSets (this=0xa922f0)
> at
> > text/qfontengine_ft.cpp:658
> > #3  0x74061ccb in QFontEngineX11FT::~QFontEngineX11FT
> > (this=0xa922f0, __in_chrg=) at
> text/qfontengine_x11.cpp:1127
> > #4  0x74061d09 in QFontEngineX11FT::~QFontEngineX11FT
> > (this=0xa922f0, __in_chrg=) at
> text/qfontengine_x11.cpp:1128
> > #5  0x7405f0ef in QRawFontPrivate::cleanUp (this=0xa5c290) at
> > text/qrawfont.cpp:699
> > #6  0x7405f194 in ~QRawFontPrivate (this=0xa5c290,
> > __in_chrg=) at text/qrawfont_p.h:94
> > #7  ~QExplicitlySharedDataPointer (this=,
> > __in_chrg=) at
> > ../../include/QtCore/../../src/corelib/tools/qshareddata.h:166
> > #8  ~QExplicitlySharedDataPointer (this=,
> > __in_chrg=) at text/qrawfont.cpp:174
> > #9  QRawFont::~QRawFont (this=, __in_chrg= out>)
> > at text/qrawfont.cpp:174
> > #10 0x74b55f46 in release_QRawFont (sipCppV=0xa087f0) at
> > sipQtGuiQRawFont.cpp:936
> > #11 0x75208e74 in forgetObject (sw=0x7fffec9bf980) at
> > siplib.c:10199
> > #12 0x75208ea9 in sipSimpleWrapper_dealloc (self=0x7fffec9bf980)
> > at siplib.c:9449
> > #13 0x77ab7b66 in subtype_dealloc (self=0x7fffec9bf980) at
> > Objects/typeobject.c:1014
> > #14 0x77a986f7 in insertdict (mp=0x641000, key=0x77f7d788,
> > hash=13056039271, value=0x77da4b30 <_Py_NoneStruct>) at
> > Objects/dictobject.c:530
> > #15 0x77a9abb4 in PyDict_SetItem (op=0x641000,
> key=0x77f7d788,
> > value=0x77da4b30 <_Py_NoneStruct>) at Objects/dictobject.c:775
> > #16 0x77a9e5dc in _PyModule_Clear (m=) at
> > Objects/moduleobject.c:138
> > #17 0x77b0d7bf in PyImport_Cleanup () at Python/import.c:445
> > #18 0x77b1a035 in Py_Finalize () at Python/pythonrun.c:454
> > #19 0x77b2aacc in Py_Main (argc=, argv= > out>) at Modules/main.c:668
> > #20 0x7747760d in __libc_start_main (main=0x400970 ,
> argc=3,
> > ubp_av=0x7fffda68, init=, fini=,
> > rtld_fini=, stack_end=0x7fffda58) at libc-start.c:226
> > #21 0x004008a9 in _start ()
> > 
> > Kovid.
> > 
> > On Fri, Oct 19, 2012 at 07:38:18PM +0530, Kovid Goyal wrote:
> >> Hi Phil,
> >> 
> >> The following snippet causes a segfault:
> >> 
> >> python -c "from PyQt4.Qt import *; app = QApplication([]); f =
> >> QRawFont.fromFont(QFont('Arial')); print f.familyName();  print 1"
> >> 
> >> However, if I explicitly delete the QRawFont first, the segfault goes
> >> away:
> >> 
> >> python -c "from PyQt4.Qt import *; app = QAp

Re: [PyQt] Help tracking down intermittent segfault using QGraphicsItem

2013-01-05 Thread Kovid Goyal
A few places. Not PyQt's fault. It's not possible to reconcile object
lifetime issues completely robustly between two different object
systems over which you have very limited control.

Here's the last example that bit me (this segfaults on linux, not other
OSes). 

python -c "from PyQt4.Qt import *; app = QApplication([]); f = 
QRawFont.fromFont(QFont('Arial'));"

The segfault can be prevented by causing the python reference to the
QRawFont to be explicitly deleted before app is deleted, like this:

python -c "from PyQt4.Qt import *; app = QApplication([]); f = 
QRawFont.fromFont(QFont('Arial')); del f"

In this case, it happens because the FreeType library (used by QRawFont)
is being destroyed before the python QRawFont object is deleted.

From the description of the OPs problem I'd guess that it is 
an object lifetime issue. Registering the child graphics item
with the scene probably causes the scene to become the owner of that
object in Qt which prevents the crash.


Kovid.

On Sat, Jan 05, 2013 at 07:12:34PM +0100, mathias.b...@gmx.de wrote:
> On 05.01.2013, 16:50:29 Andreas Pakulat wrote:
> [...]
> > Often a segfault is caused by using a pointer (in C++) which points to
> > a memory location thats not valid anymore, for example because the
> > object has been deleted already. In the context of PyQt this can
> > happen when you stop keeping references to objects that or instances
> > of C++-provided classes in python. In such a case the C++ parts of the
> > object will be deleted and thus any other C++ code that has a
> > reference to the object will crash when it tries to access the object.
> > I think thats the most common problem one encounters with PyQt4.
> 
> While this is certainly true in general, I'd say that sip goes to
> great length in order to avoid that kind of crash by carefully
> observing who owns what. It is aware of the parent-child memory
> management of Qt. A python program should never be able to cause a
> crash. Is there any place in PyQt where the Python code has to keep
> references to keep the program going?
> 
> Best Regards,
> Mathias Born
> 
> 
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,50e86d3047621890519808!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] Help tracking down intermittent segfault using QGraphicsItem

2013-01-06 Thread Kovid Goyal
Since it seems to be a fix, which indicates the issue is object
ownership/lifetime, you can try an approach that avoids the warning.

For example, dont give item1 a parent, instead add it to the scene, and
when deleting item0 add code to manually delete item1. 

You can also try using the API in
http://www.riverbankcomputing.com/static/Docs/sip4/python_api.html
to manually manage the object ownership, deletion semantics.

Kovid.

On Mon, Jan 07, 2013 at 02:05:27AM +0430, Lee Harr wrote:
> 
> >> The strangest part is that if I manually add item1 to the scene
> >> (should not be needed since the child is automatically added when
> >> the parent is added) I do not get the segfault.
> 
> 
> > From the description of the OPs problem I'd guess that it is
> > an object lifetime issue. Registering the child graphics item
> > with the scene probably causes the scene to become the owner of that
> > object in Qt which prevents the crash.
> 
> 
> If I read you correctly, you are saying that this is probably
> "fixing" the problem.
> 
> So, if I can get over not wanting the ugly warning, it's probably
> safe to ship it like this.
> 
> 
> I have gone through and everywhere I was throwing away
> python references to old Qt objects I instead just hold on to
> the old one, and that has reduced the chance of a segfault
> significantly, but it still happens occasionally. So I'm still
> searching for objects that are getting released too early.
> 
> Manually adding that one object to the scene seems to
> fix it completely...
> 
> 
> Thanks for your help!
> 
> 
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,50e9ee2e47621161344975!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Re: [PyQt] headless browsing via PyQT4

2013-02-16 Thread Kovid Goyal
xvfb

Kovid.

On Sat, Feb 16, 2013 at 07:27:04PM -0500, Jiangcheng Bao wrote:
> I am trying to achieve headless browsing via QWebView or QWebPage, but
> looks like the application would require a X server to connect to,
> even if I don't call the .show() method.
> 
> The sample code at
> http://webscraping.com/blog/Scraping-JavaScript-webpages-with-webkit/,
> that does not call .show() method, but would fail with the following
> error when running under terminal without DISPLAY set actually:
> 
> cannot connect to X server
> 
> I also tried to use module webkit.WebkitBrowser on
> http://webscraping.com/, by creating WebkitBrowser and set gui=False
> in the init method, but it also fails with the same error when there's
> no DISPLAY.
> 
> Anybody has some idea how do I actually achieve headless browsing, by
> either subclass QWebView, or webkit.WebkitBrowser?
> 
> Thanks
> Jiangcheng Bao
> ___
> PyQt mailing listPyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 
> !DSPAM:3,512023f0281101428382049!
> 
> 

-- 
_

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre-ebook.com
_


signature.asc
Description: Digital signature
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt