[Lazarus] Carbon: GetTextExtentPoint and Access Violation

Tom Gregorovic _tom_ at centrum.cz
Tue Jun 17 10:38:04 CEST 2008


On Tue, Jun 17, 2008 at 9:37 AM, Bent Normann Olsen <bent at earmaster.com> wrote:
> Hi again,
>
> I tried to make a simple test by reading different components canvas
> handles, like:
>
>  Caption := IntToStr(ToolButton1.Canvas.Handle);
>  Caption := Caption+' '+ IntToStr(ToolBar1.Canvas.Handle);
>  Caption := Caption+' '+ IntToStr(Panel3.Canvas.Handle);
>  Caption := Caption+' '+ IntToStr(Panel2.Canvas.Handle);
>  Caption := Caption+' '+ IntToStr(Panel1.Canvas.Handle);
>  Caption := Caption+' '+ IntToStr(Form1.Canvas.Handle);
>
> They all return the same handle (one component is parent for the next
> component), but more interestingly the test crashes on the main application,
> and not on a isolated test application. And it only crashes if I read 6
> handles, not 5 or less - strange.

The handles are the same, because they point to fake object
DefaultContext. The reason is that you can't paint on Carbon controls
outside paint event. DefaultContext is a bitmap canvas.
Can you debug the exact line which causes the crash?

>
> And also I tried different compiler options, and I that found if I check
> "Use Heaptrc Unit (-gh)" the displaying of hint don't crash no more, neither
> does the above test. But the application crash on exit.
>
> Could this be a problem with memories on Carbon for larger applications with
> many components? I tried to increase "Heap Size" with no luck.

It sounds really strange, what FPC and platform (intel or ppc) do you use?

Tom



More information about the Lazarus mailing list