Recent

Author Topic: TListView.OnChange Event Firing Bug  (Read 1052 times)

msintle

  • Full Member
  • ***
  • Posts: 135
TListView.OnChange Event Firing Bug
« on: September 12, 2024, 02:12:18 am »
Lazarus trunk affected, reproduces on macOS.

Previously:

When you select a new TListItem, TListView.OnChange fired with the deselected item first, and then with the selected item.

Currently:

TListView.OnChange fires with the newly selected item first, and then the deselected item.

This breaks a lot of code which assumes, based on historic behavior, that the old item is deselected first, and then the new item is selected (instead of doing it chronologically inaccurately).

Bart

  • Hero Member
  • *****
  • Posts: 5356
    • Bart en Mariska's Webstek
Re: TListView.OnChange Event Firing Bug
« Reply #1 on: September 12, 2024, 11:19:05 am »
Please report n the bugtracker.
It would be helpfull if you can find the guilty revision (use 'git bisect' for that).

Do you know if this happens on Cocoa WS only, or also on e.g. Windows?

Bart

wp

  • Hero Member
  • *****
  • Posts: 12353
Re: TListView.OnChange Event Firing Bug
« Reply #2 on: September 12, 2024, 11:43:58 am »
On Windows it first fires with "Selected= false", and then with "Selected=true".

Bart

  • Hero Member
  • *****
  • Posts: 5356
    • Bart en Mariska's Webstek
Re: TListView.OnChange Event Firing Bug
« Reply #3 on: September 12, 2024, 12:20:57 pm »
So, one should not rely on order but on Selected param?

Bart

msintle

  • Full Member
  • ***
  • Posts: 135
Re: TListView.OnChange Event Firing Bug
« Reply #4 on: September 12, 2024, 12:47:44 pm »
On Windows it first fires with "Selected= false", and then with "Selected=true".

So the issue seems isolated to macOS, and does not happen on Windows.

msintle

  • Full Member
  • ***
  • Posts: 135
Re: TListView.OnChange Event Firing Bug
« Reply #5 on: September 12, 2024, 12:48:19 pm »
So, one should not rely on order but on Selected param?

Bart

That's not viable.

It doesn't work that way on either Delphi or Lazarus for Windows, the behavior change is a breaking bug for all legacy code on the macOS side.

It is perfectly reasonable to have existing code that relies on the order in which the Selected parameter is being triggered (first false, then True):

This indicates an old TListItem is being deselected, and then a new TListItem is being selected.

However when this firing order is changed (from True to false), it then seems to existing code like a new TListItem is being selected without prior notification of the de-selection of the old TListItem, and then the new TListItem is again being de-selected.

So this breaks a lot of important code and leaves the program running thinking there is no selected TListItem, when there actually is.
« Last Edit: September 12, 2024, 01:01:26 pm by msintle »

msintle

  • Full Member
  • ***
  • Posts: 135
Re: TListView.OnChange Event Firing Bug
« Reply #6 on: September 12, 2024, 01:35:50 pm »
Please report n the bugtracker.
It would be helpfull if you can find the guilty revision (use 'git bisect' for that).

Do you know if this happens on Cocoa WS only, or also on e.g. Windows?

Bart

Reported here:
https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41134

wp

  • Hero Member
  • *****
  • Posts: 12353
Re: TListView.OnChange Event Firing Bug
« Reply #7 on: September 12, 2024, 01:38:35 pm »
On Windows it first fires with "Selected= false", and then with "Selected=true".

So the issue seems isolated to macOS, and does not happen on Windows.
Maybe also on Linux, I did not check this. But since there were a lot of changes in the cocoa widgetset recently, I guess that you are right. It would be great if you could try to find out the guilty commit and mention it in a bug report. I tried to do it myself, but I have macOS only in a VM and cannot build Lazarus/cocoa after Sept 04 (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41133), and the last working version does not yet show the issue (several Listview-related commits were made after this date).

msintle

  • Full Member
  • ***
  • Posts: 135
Re: TListView.OnChange Event Firing Bug
« Reply #8 on: September 12, 2024, 04:14:58 pm »
On Windows it first fires with "Selected= false", and then with "Selected=true".

So the issue seems isolated to macOS, and does not happen on Windows.
Maybe also on Linux, I did not check this. But since there were a lot of changes in the cocoa widgetset recently, I guess that you are right. It would be great if you could try to find out the guilty commit and mention it in a bug report. I tried to do it myself, but I have macOS only in a VM and cannot build Lazarus/cocoa after Sept 04 (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41133), and the last working version does not yet show the issue (several Listview-related commits were made after this date).

TBH I don't know how to do that. I can only ever install Lazarus through FPCUPDLX, if you have directions to check it that way, don't hesitate to let me know.

Bart

  • Hero Member
  • *****
  • Posts: 5356
    • Bart en Mariska's Webstek
Re: TListView.OnChange Event Firing Bug
« Reply #9 on: September 12, 2024, 06:55:04 pm »
Since you have Lazarus trunk, I guess that fpcupdeluxe has installed git, and used git to pull the Lazarus sources.
What you need to know is a commit where TListView still behaved correctly.
You already have a commit (your curren version) where it is broken.
Then you can use git bisect to find the revision that broke it.
You can do git --help bisect on the commandline or search online for it.

Bart

Bart

  • Hero Member
  • *****
  • Posts: 5356
    • Bart en Mariska's Webstek
Re: TListView.OnChange Event Firing Bug
« Reply #10 on: September 12, 2024, 07:10:00 pm »
Apparently it was fixed.
Just do a git pull to update the sources, rebuild your program and see if it works again as expected.

Bart

msintle

  • Full Member
  • ***
  • Posts: 135

msintle

  • Full Member
  • ***
  • Posts: 135
Re: TListView.OnChange Event Firing Bug
« Reply #12 on: September 17, 2024, 10:11:04 pm »
Does anybody else see problems with trunk macOS Lazarus's TListView?

I am seeing additional problems after rich's quick fix, including all out application crash, and other strange issues.

Creating a reproducing project has been challenging, so wondering if anyone else is running into problems.

If you are using TListView, please try it out!

msintle

  • Full Member
  • ***
  • Posts: 135
Re: TListView.OnChange Event Firing Bug
« Reply #13 on: September 19, 2024, 07:19:54 pm »
rich has again fixed this issue - thank you!

There's one more behavioral difference from Lazarus 3.4 which I've updated the bug report with (the TListView.OnChange event no longer fires when I select list items in code).

I can't be sure there aren't others, as I am reporting the ones discovered by our own regression testing.

msintle

  • Full Member
  • ***
  • Posts: 135
Re: TListView.OnChange Event Firing Bug
« Reply #14 on: September 20, 2024, 02:12:34 pm »
Here's the new issue for the new leftover matter:

https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41151

Hasn't been assigned to rich yet, keeping fingers crossed!

 

TinyPortal © 2005-2018