Forum > QT

[Solved] Custom Control causes QTransform error

(1/4) > >>

alanphys:
Hi

I recently upgraded to Lazarus 2.2.0. I have a custom control DTrackBar in one of my production apps which I have used for many years that is now giving a SIGSEGV error (runtime error 216) under QT5. Other applications that don't have this control run correctly. I am running Fedora 34 with QT version 5.15.2.

The control and app compiles and runs correctly under Windows and GTK2. The interesting thing is that the error only occurs once under QT5 after which the app and control work correctly. This, to me, indicates an initialisation problem. I have gone through the code of the control and as far as I can determine everything is being instantiated properly. It seems to me that on the first run the device context (Canvas) is getting lost somewhere.

A stack trace from a simple project containing only the control is included below:

I have:
Installed version 1.2.10 of Dave Bannon's libQt5Pas rpm package. (big thanks @dbannon)
Uninstalled this and installed the source and compiled from scratch (I've had previous issues with glibc).
Deleted this and reverted back to version 1.2.9 shipped with Lazarus 2.2.0. Compiled this from scratch again.

Both versions give the same error. The last working version of libQt5Pas was 1.2.6 from Lazarus 2.0.12.

I have stepped through the control code. Canvas.Draw is called with a valid bitmap and the Canvas appears to exist. I suspect that the control is not initialising something that was previously initialised by default.

If any of the QT5 gurus can shed some light or give me some pointers where to look I would be grateful.

Regards
Alan

Stack Trace
#0 SYSTEM_$$_HANDLEERRORADDRFRAME$LONGINT$POINTER$POINTER at :0
#1 QTransform::type() const at :0
#2 QRasterPaintEngine::drawImage(QRectF const&, QImage const&, QRectF const&, QFlags<Qt::ImageConversionFlag>) [clone .part.0] at :0
#3 QPainter::drawPixmap(QRectF const&, QPixmap const&, QRectF const&) at :0
#4 QPainter_drawPixmap11 at :0
#5 RENDERPIXMAP(0x7fffffffc110, 0xe7b130, 0x0, false) at qt5/qtwinapi.inc:6931
#6 STRETCHMASKBLT(0x7fffe5c1fd50, 140736935857984, 5, 15, 10, 20, 140736935859904, 0, 0, 10, 20, 0, 0, 0, 13369376) at qt5/qtwinapi.inc:7016
#7 STRETCHMASKBLT(140736935857984, 5, 15, 10, 20, 140736935859904, 0, 0, 10, 20, 0, 0, 0, 13369376) at include/lclintf.inc:457
#8 DRAW(0x7fffe5c779c0, 0x7fffe5be35c0, {LEFT = 5, TOP = 15, RIGHT = 15, BOTTOM = 35, TOPLEFT = {X = 5, Y = 15}, BOTTOMRIGHT = {X = 15, Y = 35}, VECTOR = {5, 15, 15, 35}}) at include/rasterimage.inc:245
#9 STRETCHDRAW(0x7fffe5be35c0, {LEFT = 5, TOP = 15, RIGHT = 15, BOTTOM = 35, TOPLEFT = {X = 5, Y = 15}, BOTTOMRIGHT = {X = 15, Y = 35}, VECTOR = {5, 15, 15, 35}}, 0x7fffe5c779c0) at include/canvas.inc:48
#10 DRAW(0x7fffe5be35c0, 5, 15, 0x7fffe5c779c0) at include/canvas.inc:26
#11 UPDATETHUMB(0x7fffe5c4cc70) at Tracker2.pas:797
#12 PAINT(0x7fffe5c4cc70) at Tracker2.pas:1157
#13 PAINTWINDOW(0x7fffe5c4cc70, 140736935857984) at include/customcontrol.inc:123
#14 PAINTHANDLER(0x7fffe5c4cc70, {MSG = 15, UNUSEDMSG = 0, DC = 140736935857984, PAINTSTRUCT = 0x7fffe5c70a20, RESULT = 0}) at include/wincontrol.inc:4857
#15 WMPAINT(0x7fffe5c4cc70, {MSG = 15, UNUSEDMSG = 0, DC = 140736935857984, PAINTSTRUCT = 0x7fffe5c70a20, RESULT = 0}) at include/wincontrol.inc:6836
#16 WMPAINT(0x7fffe5c4cc70, {MSG = 15, UNUSEDMSG = 0, DC = 140736935857984, PAINTSTRUCT = 0x7fffe5c70a20, RESULT = 0}) at include/customcontrol.inc:103
#17 SYSTEM$_$TOBJECT_$__$$_DISPATCH$formal at :0
#18 ?? at :0
#19 ?? at :0
#20 ?? at :0
#21 ?? at :0
#22 .Ld264 at :0
#23 VMT_$CONTROLS_$$_TGRAPHICCONTROL$indirect at :0
#24 ?? at :0
#25 ?? at :0
#26 ?? at :0
#27 ?? at :0
#28 ?? at :0
#29 WNDPROC(0x7fffe5c4cc70, {MSG = 15, UNUSEDMSG = 0, WPARAM = 140736935857984, LPARAM = 140737048414752, RESULT = 0}) at include/control.inc:2282
#30 WNDPROC(0x7fffe5c4cc70, {MSG = 15, UNUSEDMSG = 0, WPARAM = 140736935857984, LPARAM = 140737048414752, RESULT = 0}) at include/wincontrol.inc:5429
#31 SLOTPAINT(0x7fffdcd9c040, 0xe14260, 0x7fffffffcd70) at qt5/qtwidgets.pas:4263
#32 EVENTFILTER(0x7fffdcd9c040, 0xe14260, 0x7fffffffcd70) at qt5/qtwidgets.pas:2783
#33 EVENTFILTER(0x7fffdcd9c040, 0xe14260, 0x7fffffffcd70) at qt5/qtwidgets.pas:17033
#34 VIEWPORTEVENTFILTER(0x7fffdcdb9400, 0x7fffffffcd70, 0x7fffffffcc5f) at qt5/qtwidgets.pas:17551
#35 QLCLAbstractScrollArea::viewportEvent(QEvent*) at :0
#36 QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject*, QEvent*) at :0
#37 QApplicationPrivate::notify_helper(QObject*, QEvent*) at :0
#38 QCoreApplication::notifyInternal2(QObject*, QEvent*) at :0
#39 QWidgetPrivate::sendPaintEvent(QRegion const&) at :0
#40 QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) at :0
#41 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) at :0
#42 QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) at :0
#43 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) at :0
#44 QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) at :0
#45 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) at :0
#46 QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) at :0
#47 QWidgetPrivate::paintSiblingsRecursive(QPaintDevice*, QList<QObject*> const&, int, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) at :0
#48 QWidgetPrivate::drawWidget(QPaintDevice*, QRegion const&, QPoint const&, QFlags<QWidgetPrivate::DrawWidgetFlag>, QPainter*, QWidgetRepaintManager*) at :0
#49 QWidgetRepaintManager::paintAndFlush() at :0
#50 QWidgetRepaintManager::sync(QWidget*, QRegion const&) at :0
#51 QWidgetWindow::event(QEvent*) at :0
#52 QApplicationPrivate::notify_helper(QObject*, QEvent*) at :0
#53 QCoreApplication::notifyInternal2(QObject*, QEvent*) at :0
#54 QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::ExposeEvent*) at :0
#55 QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) at :0
#56 xcbSourceDispatch(_GSource*, int (*)(void*), void*) at :0
#57 g_main_context_dispatch at :0
#58 g_main_context_iterate.constprop at :0
#59 g_main_context_iteration at :0
#60 QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) at :0
#61 APPWAITMESSAGE(0x7fffe5c1fd50) at qt5/qtobject.inc:313
#62 IDLE(0x7fffe5c1f8f0, true) at include/application.inc:453
#63 HANDLEMESSAGE(0x7fffe5c1f8f0) at include/application.inc:1265
#64 RUNLOOP(0x7fffe5c1f8f0) at include/application.inc:1383
#65 APPRUN(0x7fffe5c1fd50, {Proc = {procedure (POINTER)} 0x7fffffffe210, Self = 0x7fffe5c1f8f0}) at qt5/qtobject.inc:292
#66 RUN(0x7fffe5c1f8f0) at include/application.inc:1371
#67 main at project1.lpr:23

zeljko:
Does it work with Qt4 ?
EDIT: In your case it crashes inside Qt library. You should check somehow input params for drawPixmap() at line 6931 in qtwinapi.inc,
eg via writeln (X,Y,Width,Height) and try to save ATempPixmap into file before call to drawPixmap() to see if they're valid. Also, what is format of that image ?

alanphys:
Thanks for the reply zeljko

I did as you suggested. The bitmap is constructed correctly and is valid (attached). The X,Y and Width,Height values are correct and valid. The device context has the correct handle.

I commented out the Canvas.Draw statement in the controls code and put a Canvas.TextOut and got a very similar error. So now I'm wondering if the device context is getting corrupted somewhere.

I can't test on QT4 as Fedora has dropped QT4 but this was working on QT5.

I will investigate further and see if I can isolate the problem. Thanks for the assistance so far.
Regards
Alan

zeljko:
I must see/test sample project to get any clue about problem. Lazarus and my projects works fine with Qt-5.15.ANY

alanphys:
Update

So this is weird. Over the weekend I thought I would do some debugging. I started Lazarus and the project loaded, compiled and ran with no problems. I normally run my laptop with a second screen attached and I do most of my work on the larger external screen. This time I was using the laptop screen only. Further experimentation showed the test project runs correctly on the laptop screen but not on the external screen.

It seems the device context for the external screen is being corrupted in some way. I will see if I can isolate it. I have attached the source code of the component. It contains a sample project if you want to look at it.

Regards
Alan

Navigation

[0] Message Index

[#] Next page

Go to full version