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
