[Qt] Wrong typecast in LCL-QT

zeljko zeljko at holobit.net
Sat Apr 4 15:38:33 CEST 2015


On 04/04/2015 12:56 PM, Juha Manninen wrote:
> 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





More information about the Qt mailing list