Lazarus

Programming => Graphics => Graphics and Multimedia => BGRABitmap and LazPaint => Topic started by: winni on September 27, 2020, 09:04:49 pm

Title: BCButton crashes while LoadFromFile
Post by: winni on September 27, 2020, 09:04:49 pm
Hi!

I try to assign a button design from the styles directory at runtime to a BCButton.

This results in a crash.  See attachment.

LoadFromFile calls somewhere a stream and that stream tries to find the token, but it finds the first char which is a '['. The stream does not like that.

Is there a workaround?

Winni



Title: Re: BCButton crashes while LoadFromFile
Post by: lainz on September 27, 2020, 10:59:03 pm
These are not in the same format if I remember correctly.

Try saving to file a BCButton you designed with the inspector at runtime. Then try loading it, it works?
Title: Re: BCButton crashes while LoadFromFile
Post by: winni on September 27, 2020, 11:11:07 pm
Hi!

I tested that and saw that it is a different format.
But LoadFromFile gives the same error message:

It cannot find the token, but finds a char.

Winni
Title: Re: BCButton crashes while LoadFromFile
Post by: lainz on September 28, 2020, 12:04:58 am
Seems a bug, but not in BGRAControls, the streaming is as you can see in the code with some FPC stuff.

Also the loading from JSON doesn't works, and it was working fine before 3.2...

I'm adding a bug report in bgracontrols to further investigate, but I've not changed anything and stopped working, so maybe a bug in FPC.
Title: Re: BCButton crashes while LoadFromFile
Post by: lainz on September 28, 2020, 12:14:58 am
Try this:

Code: Pascal  [Select][+][-]
  1.   BCButton1.SaveToFile('button.bcbtn');
  2.   BCButton2.AssignFromFile('button.bcbtn');

It works. Is AssignFromFile what you need to call. I don't remember why I choose that naming...

But this JSON loading doesn't works, I'm not sure why, it was working, but on 3.0.4 and 3.2 doesn't work anymore.  :(

Code: Pascal  [Select][+][-]
  1.   BCButton1.SaveToJSON('button.bcbtn');
  2.   BCButton2.LoadFromJSON('button.bcbtn');    
Title: Re: BCButton crashes while LoadFromFile
Post by: winni on September 28, 2020, 01:25:29 am
Hi!

The example with AssignFile works! Thanx.

But how to load the predifined *.btbtn files in the directory styles ??


And about the naming of AssignFile:

We call now the fork a spoon.
And the spoon we call hammer.

To much Monty Python???

Winni
Title: Re: BCButton crashes while LoadFromFile
Post by: lainz on September 28, 2020, 01:50:01 am
The LoadFromFile is used internally, it should be private.  ::)

To load the predefined styles, you maybe want to assign it from the object inspector, and save it at runtime, then you have a copy that works.

Both different people designed that, Dibo the author of BCButton made the object inspector, and I added the functionality to load / save from file at runtime. These are not the same.

Also notice that maybe TBCButton and TBCButtonFocus behaves differently due to naming of internal components classes.
Title: Re: BCButton crashes while LoadFromFile
Post by: winni on September 28, 2020, 11:02:48 am
@Lainz


Hi!

File format jungle:

The file format of the delivered styles in the directory BCButton/styles is some homebrew Ini file.

The file format of TBCButton.SaveToFile is Lazarus lfm.

Is there some trick or tool to convert them: IniFile <-> lfm ????

Would be nice.

Winni
TinyPortal © 2005-2018