* * *

Author Topic: TStrings crash in Paint  (Read 341 times)

daz

  • Full Member
  • ***
  • Posts: 102
    • http://matt-shaffer.com
TStrings crash in Paint
« on: August 17, 2017, 10:00:39 am »
Here's a work in progress custom component I was making
https://pastebin.com/DdDUiTRj

If I have FItems anywhere in the Paint method, the thing dies with mysterious errors.

Trying the horrendous method recommended on the Wiki page of opening lazarus.lpi and then starting lazarus and debugging in that way...

It SIGSEGVs at FFFFFFFF. The assembler simply says <error>

With the nil check commented out, at one point it SIGSEGV'd but gave highlighted the line "if FItems.Count > 0 then "

With all references of FItems removed from Paint, there are no crashes. I cannot figure out why. My debugging (and programming as well) skills are not great  :-\

In SetItems, it appears FItems is set correctly (as shown from correct data from the kludgy ShowMessage).

What am I trying to do? Well, I am writing a simple vertical TListView component. I want the user to be able to edit the TStrings in the Lazarus object inspector (and have them save correctly, which it doesn't but I'm not sure if that's related). Then those TStrings will be drawn by the component.

I am using Lazarus 1.6.4 SVN revision 54278 64 bit on Windows 10. Thanks for your time

taazz

  • Hero Member
  • *****
  • Posts: 4486
Re: TStrings crash in Paint
« Reply #1 on: August 17, 2017, 10:45:50 am »
Here's a work in progress custom component I was making
https://pastebin.com/DdDUiTRj

If I have FItems anywhere in the Paint method, the thing dies with mysterious errors.

Trying the horrendous method recommended on the Wiki page of opening lazarus.lpi and then starting lazarus and debugging in that way...

It SIGSEGVs at FFFFFFFF. The assembler simply says <error>

With the nil check commented out, at one point it SIGSEGV'd but gave highlighted the line "if FItems.Count > 0 then "

With all references of FItems removed from Paint, there are no crashes. I cannot figure out why. My debugging (and programming as well) skills are not great  :-\

In SetItems, it appears FItems is set correctly (as shown from correct data from the kludgy ShowMessage).

1) if you need to use FItmes in the object inspector then you need to create them on the constructor you can't pass them from outside.
2) if you simple reference outside items then you need to make sure that the outside items are not destroyed/reinitialized while you are processing them.

All in all create and manage the FItems internally in your control, do not rely on external objects that you have no control over.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus