[Lazarus] GetParent returning Self
Martin Grajcar
maaartinus at gmail.com
Sat Aug 1 08:52:48 CEST 2015
In /usr/share/lazarus/1.2.6/lcl/interfaces/carbon/carbonprivatewindow.inc:299
(CarbonWindow_MouseProc ) there's the following code
while Assigned(Widget) and not Widget.IsEnabled do
begin
// Here we need to avoid an endless loop which might occur in case
// GetParent returns the same widget that we passed
lTmpWidget := TCarbonWidget(CarbonWidgetset.GetParent(HWND(Widget)));
if lTmpWidget = Widget then Break;
Widget := lTmpWidget;
end;
In our application, it indeed happens somehow, that the condition lTmpWidget
= Widget holds. This test helps to break the infinite cycle, but
function TCarbonWidgetSet.GetParent(Handle: HWND): HWND;
in /usr/share/lazarus/1.2.6/lcl/interfaces/carbon/carbonwinapi.inc:1794
gets also used from elsewhere, namely
from /usr/share/lazarus/1.2.6/lcl/include/winapi.inc:432
function GetParent(Handle : HWND): HWND;
which gets used from C code handling the event loop. It looks like there's
a similar problem happening there, an endless loop keeping the CPU busy and
the application dead.
As a workaround, I appended
if Result = Handle then Result := 0;
to TCarbonWidgetSet.GetParent but this feels hacky.
My questions are:
1. Am I right assuming that a windows having itself as parent is always
wrong?
2. Is there a simple way how to find where this happens? I know it's not in
in TCarbonWidgetSet.SetParent.
3. Is my workaround correct?
Regards, Martin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150801/1dd40fb8/attachment-0002.html>
More information about the Lazarus
mailing list