GtkTreeView: "changed" signal sent when clicking an already selected row in GTK_SELECTION_MULTIPLE mode
Steps to reproduce
Create a tree view with a the tree selection mode set to GTK_SELECTION_MULTIPLE
and connect a signal changed
handler for the tree selection.
A modified example is attached for both Gtk3 and Gtk4. Compile and run the attached programs.
-
bug3.c is the Gtk3 version, compile with
gcc bug3.c -o bug3 $(pkg-config --cflags --libs gtk+-3.0)
-
bug4.c is the Gtk4 version, compile with
gcc bug4.c -o bug4 $(pkg-config --cflags --libs gtk4)
- Run the resulting binary from the terminal.
- Repeatedly left click the first row
Row 0
- Hold down the
SHIFT
key and repeatedly left click rowRow 1
Current behavior
Each left click will print a Selection changed X time(s)
message even when the clicked row is already selected, meaning the selection changed
signal is emitted although the selection has not changed.
Expected outcome
The changed
signal should only be emitted when the selection actually changes, as is the case when setting the selection mode to GTK_SELECTION_SINGLE
.
I am aware that the docs have a fuzzy statement reading:
[...] and it may occasionally be emitted when nothing has happened.
The problem here is that for the detection of a true selection change, the developer would have to cache the last selection and compare it on every changed
signal.
Version information
Arch Linux & git
Both Gtk3 and Gtk4
- Gtk 3.24.34
- Gtk 4.8.2
Additional information
Terminal output:
Changed 1 time(s).
Changed 2 time(s).
Changed 3 time(s).
Changed 4 time(s).
Changed 5 time(s).
Changed 6 time(s).
Changed 7 time(s).
Changed 8 time(s).
Changed 9 time(s).