Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2015-04

Wrong typecast in LCL-QT

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

In r48618 I added a test for a valid typecast in QtObjectFromWidgetH. It raises an exception but it is cought somewhere, it can be seen only under a debugger.

Earlier when a wrong type was passed, MDIFocusFixNeeded in TQtWidgetSet.FocusChanged used OldWidget.LCLObject which contained garbage.

Zeljko, to reproduce the error, try opening a project without an icon. For example the ScrollboxControls demo I sent you earlier has no icon. Running Lazarus under debugger, there is first an exception "unable to load icon" or similar. Then my new test + exception is triggered. The returned variant is not even a TObject. I noticed it when I tried to read Obj.Classname. FPC raised an exception then.

I believe the error happens in many other situations, too.

Regards,
Juha

Juha Manninen
to Juha Manninen
Juha Manninen wrote
Earlier when a wrong type was passed, MDIFocusFixNeeded in TQtWidgetSet.FocusChanged used OldWidget.LCLObject which contained garbage.

Actually it was NewWidget.LCLObject that contained garbage.

Anyway, now I am getting the exception every time when closing an IDE window. I did not notice it earlier.

Juha

zeljko
to Juha Manninen: In r48618 I added a test for a valid typecast in QtObjectFromWidgetH. It raises an…
Juha Manninen wrote 14 lines
In r48618 I added a test for a valid typecast in QtObjectFromWidgetH. It raises an exception but it is cought somewhere, it can be seen only under a debugger. Earlier when a wrong type was passed, MDIFocusFixNeeded in TQtWidgetSet.FocusChanged used OldWidget.LCLObject which contained garbage. Zeljko, to reproduce the error, try opening a project without an icon. For example the ScrollboxControls demo I sent you earlier has no icon. Running Lazarus under debugger, there is first an exception "unable to load icon" or similar. Then my new test + exception is triggered. The returned variant is not even a TObject. I noticed it when I tried to read Obj.Classname. FPC raised an exception then.

I don't get any error here (32bit Qt-4.7.4 and 64bit Qt-4.8.6 (Fedora 14 & 19). Besides that QtObjectFromWidgetH searches for "lclwidget" property inside QWidget handle and returns valid TQtWidget handle (only in that case, QWidget is always destroyed and nulled and "lclwidget" property also is removed before TQtWidget is released). LCLObject can be garbage if it's freed in the meantime, but TQtWidget should be still valid if QWidget passed in that function is valid and have property "lclwidget".
I doubt that problem relies in QtObjectFromWidgetH.

I believe the error happens in many other situations, too.

Give me more details about platform and qt version that you use.

zeljko

Juha Manninen

---------- Forwarded message ----------

Earlier message 27 lines
From: Juha Manninen Date: Sat, Apr 4, 2015 at 7:23 PM Subject: Re: [Qt] Wrong typecast in LCL-QT To: zeljko On Sat, Apr 4, 2015 at 4:38 PM, zeljko wrote: > Give me more details about platform and qt version that you use. Mint 17.1, 64-bit, QT 4.8.5. KDE 4.14.2. The exception is raised consistently when I close an IDE window, eg. Watches or Assembly window. Yes, QtObjectFromWidgetH searches for "lclwidget" property but still a wrong type is returned. QObject_property(QObjectH(WidgetH), V, 'lclwidget'); returns a wrong type but Obj := TObject(QVariant_toULongLong(V, @Ok)); passes as valid. One choice is that my KWin settings for auto-focusing windows brake QT somehow. I will test with other settings ... Let's keep the test + exception there anyway. Many people use Mint Linux, maybe somebody else can reproduce. Juha
Juha Manninen
to Juha Manninen
Juha Manninen wrote
One choice is that my KWin settings for auto-focusing windows brake QT somehow. I will test with other settings ...

KWin settings make no difference in my tests.

Juha