[PyKDE] QPixmap problem under Windows?

Phil Thompson phil at riverbankcomputing.co.uk
Fri Jul 22 18:41:09 BST 2005


On Friday 22 July 2005 4:19 pm, Erik Åldstedt Sund wrote:
> On Fri, Jul 22, 2005 at 10:42:59AM -0400, Andrew Bushnell wrote:
> > Erik Åldstedt Sund wrote:
> > >Hi,
> > >
> > >We've got a problem which we hope some of you have at least seen
> > >before, or maybe even know how to solve... When we run our unittest
> > >suite under Windows we get the following warning/error messages from
> > >Qt:
> > >
> > >	ASSERT: "src_dc && dst_dc" in kernel\qpaintdevice_win.cpp (388)
> > >	...ASSERT: "src_dc && dst_dc" in kernel\qpaintdevice_win.cpp (388)
> > >
> > >Somewhere else in our tests it may print something like:
> > >
> > >	...ASSERT: "hBitmap" in kernel\qpixmap_win.cpp (117)
> > >	ASSERT: "data->realAlphaBits" in kernel\qpixmap_win.cpp (118)
> > >
> > >and segfault. If we set up our test system to ignore the test that
> > >segfaults it gets a little longer, but now the screen gets all messed
> > >up and the computer hangs! Before it hangs it displays something like
> > >the following two outputs:
> > >
> > >	.QPixmap::setMask: The pixmap and the mask must have the same size
> > >	ASSERT: "src_dc && dst_dc" in kernel\qpaintdevice_win.cpp (388)
> > >	QPainter::begin: Cannot paint null pixmap
> > >	ASSERT: "src_dc && dst_dc" in kernel\qpaintdevice_win.cpp (388)
> > >	QPainter::end: Missing begin() or begin() failed
> > >	QPixmap::setMask: The pixmap and the mask must have the same size
> > >	.QPixmap::setMask: The pixmap and the mask must have the same size
> > >	ASSERT: "src_dc && dst_dc" in kernel\qpaintdevice_win.cpp (388)
> > >	QPainter::begin: Cannot paint null pixmap
> > >
> > >	.QPainter::begin: Cannot paint null pixmap
> > >	QPainter::begin: Cannot paint null pixmap
> > >	QPainter::end: Missing begin() or begin() failed
> > >	QPainter::begin: Cannot paint null pixmap
> > >	ASSERT: "src_dc && dst_dc" in kernel\qpaintdevice_win.cpp (388)
> > >	QPainter::end: Missing begin() or begin() failed
> > >	QImage::convertDepth: Image is a null image
> > >	QPixmap::convertFromImage: Cannot convert a null image
> > >	QCursor: Cannot create bitmap cursor; invalid bitmap(s)
> > >
> > >This output is very strange as we've never seen anything like this
> > >under Linux. Also the application itself seems to run very fine under
> > >both platforms. To complicate things further:
> > > * running each test-case one-by-one does not crash the computer
> > >   (though some of the warning/error messages from Qt still appears on
> > >   the screen).
> > > * running one-by-one test in each testcase, we see no warning/error
> > >   messages from Qt at all.
> > >
> > >If someone has seen anything like this before, or knows how to solve
> > >this problem, we would be very grateful!
> > >
> > >
> > >[ Some background: ]
> > >
> > >We are developing a cross-platform application using Python 2.3 and
> > >PyQt 3.14.1 with Qt 3.3.4.
> > >
> > >We have written testcases that tests correct behaviour in
> > >GUI-elements. When doing so we need to create a QApplication instance
> > >before each test is run. This QApplication instance is then deleted
> > >after the test is run in the following manner:
> > >
> > >	QTimer.singleShot(0, self.qapplication.quit)
> > >	self.qapplication.exec_loop()
> > >	del self.qapplication
> > >
> > >thus starting the GUI-thread, and quitting it first thing when it has
> > >started, before deleting it.
> > >
> > >
> > >Greetings,
> > >Erik.
> >
> > Erik,
> >
> > It appears that you possibly are running out of resource handles or
> > something on your windows system. If you have not done so already, you
> > may want to look at using a cache for your QPixMaps and reuse object,
> > rather than create one each time. We had similar problems and when
> > turning to a caching mechanism, our problems disappeared. You should
> > also verify that the objects are getting cleaned up properly.
>
> The QPixmap objects are allocated in code that we don't control (by
> other Qt objects), so it's impossible for us to reuse objects through
> a cache.
>
> Furthermore we have tried running the garbage collector (gc.collect())
> and it seems to do a proper clean-up. After deleting the QApplication
> object, the static call to QApplication.allWidgets() returns an empty
> list. Also the static call to QObject.objectTrees() returns an empty
> list. This should indicate that the objects are properly cleaned
> up. Is there any other ways to look for unproperly cleaned-up objects?
>
> Btw. thanks for the quick response!

You might want to try current SIP and PyQt snapshots which support Python's 
cyclic garbage collector.

Phil




More information about the PyQt mailing list