Recent

Author Topic: Linux quirky behaviour  (Read 3170 times)

MikeFinch

  • Jr. Member
  • **
  • Posts: 79
Linux quirky behaviour
« on: August 08, 2018, 08:46:48 am »
I have complained for years about the fact that the columns method does not work in a listbox under linux. In Windows it does.

It just so happens I have just found (together with a similar quirk nearby in the same .pas file) - more later - some strange behaviour.
I will present the code that I use for the two members of a submenu >>

procedure TChmenus.ActivesClick(Sender: TObject);   // the second almost identical procedure is OtherClick(Send ...
var
  i : smallint;
begin
  ActFile := 0;   // '1' in the OtherClick version
  CurrPlayers.ListBox1.Clear;

  CurrPlayers.caption := 'Active ' + MyCodes[integer(MyCode)] + ' Players : ' + inttostr(MaxRec[ActFile]);   // this is line A

  CurrPlayers.Show;
  for i := 0 to MaxRec[ActFile]-1 do
    CurrPlayers.ListBox1.Items.Add(KList[ActFile,i].name);
end;

Now, in linux these procedures seem to gum up (freeze) the program. So I have to use Ctrl-Alt-Esc to return to the IDE!
However, if I do a small shuffle of the spaces in only ONE of the two line A's  shown, the program runs OK. Also OK if the second line A is edited also.
You can see (hopefully) how I have shifted some spaces >>

CurrPlayers.caption := 'Active' + ' ' + MyCodes[integer(MyCode)] + ' ' + 'Players : ' + inttostr(MaxRec[ActFile]);

I have moved the space after Active to a separate space to the right and the space before Players to before 'Players : '.
Note that if I change only ONE of the two procedures then the program runs OK. It doesn't matter which procedure.

I found a similar effect last year (12 Sept 2017), as follows.

Panel1.Caption := MyCodes[integer(MyCode)];    // this didn't work.

Inserting a space before MyCodes and one afterwards caused the program to work!!

Does anyone know what on earth is going on here? And am I making some coding mistake(s) - especially with using integer() ?

My Windows program works as desired except for colouring some buttons where it fails (a minor point). Linux won't behave with some bordericons (as I have complained previously about).

MikeFinch (and when is 'columns' going to work in linux?) > :D

PS >> "Proud As Punch" at the moment : I have managed to make an installer for the Windows version of my program (using Inno Setup script). I was forced into this because potential (Windows) users just cannot follow simple (to me) instructions re placing files in folders and subfolders.

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Linux quirky behaviour
« Reply #1 on: August 08, 2018, 09:02:22 am »
Why don't you use beginupdate and endupdate? This is not in any way Linux specific.
Specialize a type, not a var.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: Linux quirky behaviour
« Reply #2 on: August 08, 2018, 11:19:47 am »
Does anyone know what on earth is going on here? And am I making some coding mistake(s) - especially with using integer() ?
Nobody will be able to tell because your description is very confusing. You mention two lines "A" but your code highlights only one. What is "MyCodes"? What is "MyCode"? What is "MaxRec"? What is "ActFile"? What is "KList"?

Be assured that shifting spaces within a string assigned to some control's caption cannot change a program's behavior. If it does the problem must be somewhere else in the code which you don't show.

MikeFinch

  • Jr. Member
  • **
  • Posts: 79
Re: Linux quirky behaviour
« Reply #3 on: August 11, 2018, 01:50:17 am »
Thaddy & wp

A) Thaddy  : Could you please expand on begin / endupdate? Never heard of them.

B) wp : MaxRec and ActFile are integers - ActFile is 0 or 1; MyCodes is an array of three; KList is a sorted array of persons names in memory. You would think spaces wouldn't affect behaviour, but this appears to be the case!

I am attaching the full .pas file (mainform.pas as mainform.txt) in the hope that this will make things clearer (though probably it won't).

Repeating what I have said before : I believe the Developers have concentrated on getting Windows to perform well with FreePascal but not so much with Linux.

Hopefully, MikeFinch [this is my second attempt to send this + the attachment. I copied the above ctrl+C and pasted here ctrl+V to have a second go - here's hoping that it works this time]

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Linux quirky behaviour
« Reply #4 on: August 11, 2018, 09:03:44 am »
Code snippets are useless. You need to show a compilable project with.lfms etc. included.
However, two immediate comments:
1 Why are you using crt in a GUI application? DOS era code mixed with an LCL event-driven windowed app is never going to work.
2 Your ChangeMode1Click method is a complete hack which does not diagnose the bugs in your program, but simply tries to ignore them in a very misguided way.

MikeFinch

  • Jr. Member
  • **
  • Posts: 79
Re: Linux quirky behaviour
« Reply #5 on: August 15, 2018, 01:21:38 am »
howardpc >> thankyou for pointing out (in your 1) the "crt" presence. crt is (was!) needed for TextColor() and TextBackGround() in Tchmenus.Registrations1Click(). These would have been the result of previous testing(s) and shouldn't now be there. So I have deleted all three!
In the same procedure, Panel1.Caption does not now apparently need the preceding and following spaces, so that also has been edited and the prior comment [adding ...] removed.

I am in the process of tweaking the code for the other "spacing" problem. I have managed to dispense with the changed space alignments that I had indicated, but am having to still solve why the program is still not working correctly. Looking at FormClose() - or FormCloseQuery()? - procedures etc. Will keep you posted when I have fixed this. When (if?) I fix it these problems will have gone away.

I'm afraid I didn't understand your point 2.

MikeFinch

Thaddy

  • Hero Member
  • *****
  • Posts: 14205
  • Probably until I exterminate Putin.
Re: Linux quirky behaviour
« Reply #6 on: August 15, 2018, 09:03:06 am »
Thaddy & wp

A) Thaddy  : Could you please expand on begin / endupdate? Never heard of them.
re-painting is time consuming compared to actual processing.
The methods (they belong to classes like TForm, Tpanel etc) temprarily stop the repaints.
If you call something like Form1.BeginFormUpdate; before you do intensive processing and call Form1.EndFormUpdate; your code will execute faster and your screen stays free of flickering.
This is just for a form, but many controls have the same feature: beginupdate/endupdate.
This is cross-platform and not related to any widgetset. It is just to prevent unnecessary painting.
Which is often the most expensive part of a routine in a GUI application....and pretty much useless until a final result.
« Last Edit: August 15, 2018, 09:06:03 am by Thaddy »
Specialize a type, not a var.

 

TinyPortal © 2005-2018