Recent

Author Topic: help with a lazarus project (solved)  (Read 2356 times)

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: help with a lazarus project
« Reply #15 on: November 24, 2022, 11:46:52 pm »
ok, I just fixed it to compile in the newer version of Laz. seems somethings have changed with the TStringList..
 There are still problems with cleanup, and I think there could be a problem with an error stating there is an Invalid type cast if you run the Check Methods debug but it does not point where to.
 In anycase. I'll attach a project file.
The only true wisdom is knowing you know nothing

whatsup

  • Jr. Member
  • **
  • Posts: 59
Re: help with a lazarus project
« Reply #16 on: November 25, 2022, 10:09:28 am »
Thank you so much. Will download it soon as i'll be on the computer

Thaddy

  • Hero Member
  • *****
  • Posts: 14163
  • Probably until I exterminate Putin.
Re: help with a lazarus project
« Reply #17 on: November 25, 2022, 11:32:26 am »
seems somethings have changed with the TStringList..
Highly unlikely. Tstrings and therefor Tstringlist is a core class and any malfunction will be picked up very quickly.
There are too many places where code depends on Tstrings.
« Last Edit: November 25, 2022, 11:36:15 am by Thaddy »
Specialize a type, not a var.

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: help with a lazarus project
« Reply #18 on: November 25, 2022, 01:48:28 pm »
@Thaddy, Throwing stones at glass windows again?

The "LoadFromFIle" is no longer a VIRTUAL method in the TStringList, so it can't be overridden like it was in the original code.

You are consistent, no doubt about that.
 :o
The only true wisdom is knowing you know nothing

whatsup

  • Jr. Member
  • **
  • Posts: 59
Re: help with a lazarus project
« Reply #19 on: November 25, 2022, 01:51:29 pm »
Quote
Highly unlikely 
interesting.
 To check this,  get an old lazarus with freepascal distribution ,
the project (which hasn't change for 7 years),
And check it your self.

whatsup

  • Jr. Member
  • **
  • Posts: 59
Re: help with a lazarus project
« Reply #20 on: November 25, 2022, 02:23:51 pm »
Quote
The "LoadFromFIle" is no longer a VIRTUAL method in the TStringList, so it can't be overridden like it was in the original code.

So this function has to be renamed, in all places ?
Thanks again for all your help.

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: help with a lazarus project
« Reply #21 on: November 25, 2022, 03:18:35 pm »
I just edited the code a bit and REINTRODUCED the method in the Object so the compiler won't complain about the old one being hidden and then in the actual implemented code I casted it back to the original TStringList instead of it doing the Inherited call.

 seems to work for the time being.
 
   :(
The only true wisdom is knowing you know nothing

whatsup

  • Jr. Member
  • **
  • Posts: 59
Re: help with a lazarus project
« Reply #22 on: November 27, 2022, 07:06:02 am »
Thanks for jamie reply, i managed to fix the project.
I had to change some object declaration to class declaration,
and to comment out the override property from LoadFromFile.
(I had also to comment one line with an undeclared variable.)
The project compile and seems to run correct.

My conclusion from this, is that something in freepascal has changed.
In the past object could be used with virtual methods.
Now it seems that no.

Again, Thank you jamie very much for your help.
Without it i would be lost.
« Last Edit: November 27, 2022, 02:58:03 pm by whatsup »

jamie

  • Hero Member
  • *****
  • Posts: 6077
Re: help with a lazarus project
« Reply #23 on: November 27, 2022, 12:09:53 pm »
Strange, I didn't have to do any of that, and I never found any undeclared variables, hmm.

 You will also find that the settings INI file is not getting closed in the Option dialog.
 or at least it's not getting Free'd.

 The Close and Destroy event is not freeing the INI file object, which is where all that un-freed memory was coming from.

 have fun.
The only true wisdom is knowing you know nothing

whatsup

  • Jr. Member
  • **
  • Posts: 59
Re: help with a lazarus project
« Reply #24 on: November 27, 2022, 12:18:44 pm »
 Correct. I checked your code to see what you did
With the undeclared var, i found that you downloaded the older project, which hasn't have it.

Thank you for the information, will check.

Thaddy

  • Hero Member
  • *****
  • Posts: 14163
  • Probably until I exterminate Putin.
Re: help with a lazarus project
« Reply #25 on: November 27, 2022, 12:33:17 pm »
@Thaddy, Throwing stones at glass windows again?

The "LoadFromFIle" is no longer a VIRTUAL method in the TStringList, so it can't be overridden like it was in the original code.

You are consistent, no doubt about that.
 :o
IF that is the case, then report  it on the bugtracker. LoadFromFile should be virtual/override, not Reintroduce. Probably an oversight.
Then again, I suffered no issues. (using daily trunk/main)
And who was the silly one that tinkered with that class?
Anyway Loadfromfile calls loadfromstream, for now,  which is left alone.
https://www.freepascal.org/docs-html/rtl/classes/tstrings.loadfromfile.html as proof. KYMS
« Last Edit: November 27, 2022, 12:45:57 pm by Thaddy »
Specialize a type, not a var.

whatsup

  • Jr. Member
  • **
  • Posts: 59
Re: help with a lazarus project (solved)
« Reply #26 on: November 27, 2022, 03:32:38 pm »
I just found a thread which discusses the problem i had,
showing that i actually did the correct fix - change object to class.
https://forum.lazarus.freepascal.org/index.php?topic=56804.0
I'm sure this behave wasn't in the past, though.
« Last Edit: November 27, 2022, 04:43:30 pm by whatsup »

 

TinyPortal © 2005-2018