Recent

Author Topic: ListBox.Items.Add misbehaving  (Read 6507 times)

MikeFinch

  • Jr. Member
  • **
  • Posts: 79
ListBox.Items.Add misbehaving
« on: October 01, 2016, 03:09:39 am »
Dear Helpers

I seem to have hit upon an intractable problem; that is why I am communicating it!

I have been testing real, with some artificial, surnames in a listbox. I know for a fact that the string array that is being listed is sorted correctly. For example, Abzz, Abzza, Austin etc.

When I create the list for display using the correctly sorted CompoundList array >>

for i := 1 to MaxRec do
      Form1.ListBox1.Items.Add(MidStr(CompoundList, 1, 36) + MidStr(CompoundList, 42, 5));


the displayed list absolutely insists on showing Abzza, Abzz, Austin etc - in other words the zz's are reversed.

It behaves similarly when I insert similar artificial surnames further down the list.

I have noticed that when I delete, say Abzza, I get Abzza, Austin etc. It appears to "know" that Abzza is really Abzz!!

I can only assume that this is a Lazarus bug. Can someone please try to emulate this error.

I don't see at all why it should be happening. Needless to say it is very irritating.

Mike Finch  :(

lainz

  • Hero Member
  • *****
  • Posts: 4608
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: ListBox.Items.Add misbehaving
« Reply #1 on: October 01, 2016, 03:20:36 am »
You can help us uploading a runnable code? Thanks.

Handoko

  • Hero Member
  • *****
  • Posts: 5376
  • My goal: build my own game engine using Lazarus
Re: ListBox.Items.Add misbehaving
« Reply #2 on: October 01, 2016, 03:27:27 am »
@MikeFinch

It can be something wrong in the code too. Can you please post the working code here? A strip down or demo version is okay, but please also supply the data that causes the error.

Bart

  • Hero Member
  • *****
  • Posts: 5468
    • Bart en Mariska's Webstek
Re: ListBox.Items.Add misbehaving
« Reply #3 on: October 01, 2016, 06:38:05 pm »
Which Lazarus version?
Which fpc version?
Which OS?
Which Widgetset?

Even with a sample application, without the above info it's just guessing.

Bart

MikeFinch

  • Jr. Member
  • **
  • Posts: 79
Re: ListBox.Items.Add misbehaving
« Reply #4 on: October 03, 2016, 05:55:09 am »
Thankyou Iainz, Handoko and Bart >>

I have made an attempt to strip down my code to a zip file and am down to a 260.3 kb zip. This is just too large. I had trouble reducing a major binary array to a single one. This would bring the size down further!

Should I try to get below 250kb and post it, especially after the next sentence?

After making the zip in linux I thought I would check in Windows >> much to my surprise there is no problem with W7!!! It is apparently a linux thing : is this Lazarus or Mageia 5? No!! >> the same error in PCLinuxOS and Kubuntu 16.04 >> seems to be LINUX!! (I used the Mageia executable for the executable testing).

I suppose I could install Lazarus in one of the other linuxes and then test (haven't bothered - so far).

Do I still need to reduce further and forward the code or are you satisfied it is the linux variant of Lazarus that is faulty?  %)

I am using the latest L1.6.0 and FPC 3.0.0 and I seem to be using gtk2.

I have had other gripes with the linux variant (border icons, comboboxes, listbox columns not working). Feel free to read my previous posts from 2009 onwards! Key words Mike, Finch.

Thanks in advance.

MikeFinch

  • Jr. Member
  • **
  • Posts: 79
Re: ListBox.Items.Add misbehaving
« Reply #5 on: October 03, 2016, 07:30:22 am »
Folks!

I have managed to remove an unneeded unit, so now the zip is down to 233.2kb.

I am attaching for your interest. Instructions >>>

1. Click on 'Association' and then 'OK'.
2. On 'ClubPairing'.
3. On 'New/Edit a Record'.
You will see a series of messages.
The first few will show the sorted CompoundList (notice zz precedes zza).
The purple rectangle will (wrongly) indicate zza before zz.
Run the same code in Windows and the correct order (zz before zza) is displayed.
SOMETHING IS WRONG WITH LINUX - see my other linux gripes as well!!

Good luck in solving some of the problems. Your feedback will be interesting. (I only wish I had the expertise to contribute solutions as well as problems................... ::)

Mike Finch

bytebites

  • Hero Member
  • *****
  • Posts: 684
Re: ListBox.Items.Add misbehaving
« Reply #6 on: October 03, 2016, 01:27:53 pm »
Linux file manager or ls-command in console does the same: abzza is before abzz j.

Bart

  • Hero Member
  • *****
  • Posts: 5468
    • Bart en Mariska's Webstek
Re: ListBox.Items.Add misbehaving
« Reply #7 on: October 03, 2016, 03:55:33 pm »
Sorting that uses Utf8ComapreString or Utf8CompareText now is handled by the OS (on Linux it is ultimately handled by the cwstring unit).

Bart

MikeFinch

  • Jr. Member
  • **
  • Posts: 79
Re: ListBox.Items.Add misbehaving
« Reply #8 on: October 06, 2016, 12:03:21 am »
Bart

You have narrowed it down to the cwstring unit.

Where do we go from here? Are there linux people/developers trawling sites such as here or is it my responsibility to inform the linux people?

I would have thought developers were forever vigilant with topics like the one I have raised!? Especially Lazarus Pascal ones!

It seems to be a general linux problem rather than a specific linux OS one.

Bart

  • Hero Member
  • *****
  • Posts: 5468
    • Bart en Mariska's Webstek
Re: ListBox.Items.Add misbehaving
« Reply #9 on: October 06, 2016, 10:09:40 am »
cwstring uses calls libc IIRC to do the comparing for us.
Nothing we can do about it.

Bart

 

TinyPortal © 2005-2018