[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] segfault with latest release
From:       "Hans-Peter Jansen" <hpj () urpla ! net>
Date:       2010-12-30 21:40:52
Message-ID: 201012302240.52629.hpj () urpla ! net
[Download RAW message or body]

On Thursday 30 December 2010, 18:18:22 Martin Airs wrote:
> On Thursday 30 Dec 2010 14:40:59 Erik Janssens wrote:
> > Hi,
> >
> > just got a stacktrace of a segfault under Linux.
> >
> > any suggestions of what I should be looking for ?

Erik, could you be a bit more verbose on the context, this is happening.

> > Thx,
> >
> > Erik
>
> I get a segfault when running the qtdemo, however if i run it with
> -software as apposed to -opengl it runs ok.
>
> I dont know, but are you using opengl in your app, can you run the
> qtdemo?

Hmm, not here:

python: 2.6
sip: 4.12.1-snapshot-1da2e2e9fa1c
qt4: 4.7.1
pyqt4: snapshot-4.8.3-1d2c3e10879e

Phil, qtdemo.py has an issue when using -use-window-mask:


/usr/share/doc/packages/python-qt4-devel/examples/demos/qtdemo> ./qtdemo.py -use-window-mask
Traceback (most recent call last):
  File "./qtdemo.py", line 88, in <module>
    mainWindow.enableMask(True)
  
File "/usr/share/doc/packages/python-qt4-devel/examples/demos/qtdemo/mainwindow.py", 
line 158, in enableMask
    self.setMask(QtCore.QRegion(region))
AttributeError: 'module' object has no attribute 'QRegion'

QRegion is in QtGui. Fix attached (first hunk).

The other hunks try to address Qt spewing this on exit:

QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.
QGLContext::makeCurrent(): Cannot make invalid context current.

The "solution" isn't nice, either.. I've tried to solve this within the 
GL context, but that attempt resulted in:

Traceback (most recent call last):
  
File "/usr/share/doc/packages/python-qt4-devel/examples/demos/qtdemo/mainwindow.py", 
line 330, in keyPressEvent
    self.quit()
  
File "/usr/share/doc/packages/python-qt4-devel/examples/demos/qtdemo/mainwindow.py", 
line 433, in stop
    viewport.context().setInitialized(False)
RuntimeError: no access to protected functions or signals for objects 
not created from Python

I don't know, if this would solve the issue in question, though.

With my patch, all three methods to quit the app (by escape key, WM quit 
and Quit button) don't make Qt spew at least.

Pete

["pyqtdemo.diff" (text/x-diff)]

--- mainwindow.py.orig	2010-12-29 04:44:29.000000000 +0100
+++ mainwindow.py	2010-12-30 22:20:56.286146091 +0100
@@ -155,7 +155,7 @@ class MainWindow(QtGui.QGraphicsView):
                     # 0, 520,
                     0, 0])
 
-            self.setMask(QtCore.QRegion(region))
+            self.setMask(QtGui.QRegion(region))
 
     def setupScene(self):
         self.scene = DemoScene(self)
@@ -327,8 +327,7 @@ class MainWindow(QtGui.QGraphicsView):
 
     def keyPressEvent(self, event):
         if event.key() == QtCore.Qt.Key_Escape:
-            self.loop = False
-            QtGui.QApplication.quit()
+            self.quit()
         elif event.key() == QtCore.Qt.Key_F1:
             s = ""
             s += "Rendering system: "
@@ -416,3 +415,11 @@ class MainWindow(QtGui.QGraphicsView):
         # Changing size will almost always hurt FPS during the change so ignore
         # it.
         self.fpsHistory = []
+
+    def closeEvent(self, event):
+        self.quit()
+
+    def quit(self):
+        self.loop = False
+        import sys
+        sys.exit(0)
--- menumanager.py.orig	2010-12-29 04:44:29.000000000 +0100
+++ menumanager.py	2010-12-30 22:20:26.804950382 +0100
@@ -156,8 +156,7 @@ class MenuManager(QtCore.QObject):
         elif userCode == MenuManager.DOCUMENTATION:
             self.showDocInAssistant(self.currentInfo)
         elif userCode == MenuManager.QUIT:
-            self.window.loop = False
-            QtCore.QCoreApplication.quit()
+            self.window.quit()
         elif userCode == MenuManager.FULLSCREEN:
             self.window.toggleFullscreen()
         elif userCode == MenuManager.ROOT:


_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic