PKGget drag tabs divider crash fix
This crash was reported as fixed when changed to using the 'gtkdialog' source from woof-CE:
https://bkhome.org/news/202508/column-resize-now-works-in-pkgget.html
Hmmm, but now the crash has come back, as reported by forum member tallboy:
https://forum.puppylinux.com/viewtopic.php?p=180992#p180992
This is far from easy to fix. So, have given the problem to Claude AI. I uploaded a partial skeleton root filesystem, the gtkdialog source, and a photo of PKGget gui, then asked Claude:
"gtkdialog" is a binary executable to create GUIs for shell
scripts. The example given here will display a GUI window.
To reproduce the problem, expand "rootfs-test.tar.gz" contents
into a Linux root filesystem, then within the filesystem, run
this:
# gtkdialog -f /tmp/petget/PPM_MAIN_GUI
Usage documentation for gtkdialog is in the rootfs-test tarball,
at /usr/share/doc/gtkdialog
Try to drag the divider between "Package" and "Description"
tabs, it does move, but immediately pressing the mouse left
button also selects the first entry, which is package
"alacarte_3.56.0-2". Upon release of the mouse button, a window
pops up, titled "PKGget Package Manager: preinstall" starting
with text "You have chosen to install package
'alacarte_3.56.0-2'" and the desktop then freezes. Mouse pointer
moves but inoperable. I am able to kill the gtkdialog binary
executable to recover mouse operation.
What is supposed to happen is that the divider will be dragged
by the mouse pointer, the "alacarte_3.56.0-2" will not be
selected.
There is a photo that shows what it will look like,
"gtkdialog-gui.png"
Also, the source for gtkdialog is "gtkdialog-0.8.5.1.tar.gz"
Reply from Claude:
I'll start by extracting both tarballs into separate
directories and looking at the GUI definition and the gtkdialog
source.
Found the likely cause in gtkdialog's source: the tree runs its
`button-release-event` actions for any release on the widget,
including column-header resize drags. Checking GTK2 behaviour
next, then I'll write a fix.
signals.c is patched (tree widgets now ignore press/release
events that come from the column-header resize area). Now adding
the second part to widget_tree.c: undoing the stray "first row
selected" side effect after a divider drag.
I found the cause and wrote a patch, but I haven't compiled or
run it. This sandbox has no GTK development headers, so the
patch is untested. I did check that it applies cleanly to the
original 0.8.5.1 source.
**Cause of the popup and freeze**
Your `PPM_MAIN_GUI` attaches these actions to `TREE1`:
```xml
<action
signal="button-release-event">/usr/local/pkgget/installpreview.sh</action>
```
gtkdialog connects that signal to the `GtkTreeView` as a whole,
and it runs the action for every release event the tree
receives. A `GtkTreeView` also receives events from its
column-header resize areas. So letting go after dragging the
divider runs `installpreview.sh` with whatever `$TREE1` holds,
as if you had clicked a row. The preinstall window then opens
while GTK still has the pointer grabbed for the resize. I
haven't confirmed that grab is what freezes the desktop, but it
fits the symptom: the pointer moves, nothing responds, and
killing gtkdialog frees it.
**Why `alacarte_3.56.0-2` gets selected**
Pressing on the divider focuses the tree view. With nothing
selected, GTK picks the first row. That is how
`installpreview.sh` ends up with "alacarte" in `$TREE1`. I
couldn't download the GTK source to confirm this, so it is from
my recollection of GTK2 behaviour.
**What the patch changes**
- **`signals.c`:** `on_any_widget_button_pressed` and
`on_any_widget_button_released` now return immediately for a
`GtkTreeView` when the event did not come from the row area
(`gtk_tree_view_get_bin_window`). Dragging a divider no longer
runs any `button-press-event` or `button-release-event` actions.
Clicks on rows work as before.
- **`widget_tree.c`:** On a header press it records whether
anything was selected. After the release, if nothing was
selected before, it clears the selection. This is a workaround
for the focus side effect, since I can't stop GTK from selecting
the row.
The patch also covers `TREE2`, the installed-packages list,
because it uses the same signals.
To try it:
```
cd gtkdialog-0.8.5.1
patch -p1 < gtkdialog-tree-header-drag.patch
./configure && make # or meson,
as you normally build it
```
Then run `gtkdialog -f /tmp/petget/PPM_MAIN_GUI` in your rootfs
and drag the divider. The rootfs binary links GTK 2
(`libgtk-x11-2.0`), so build against GTK 2 to match.
Two things I noticed in the GUI file:
- It points at `/usr/local/pkgget/installpreview.sh`, but the
tarball only has `/usr/local/petget/installpreview.sh`. If that
path is wrong on your system, the action fails quietly. Your
report shows a preinstall window popping up, so it may exist
there.
- The selection-clearing part is the one I'm less sure of. If
the first row still ends up selected after you apply the patch,
tell me and I'll adjust it. The release suppression in
`signals.c` should still stop the popup and the freeze.
My reply:
Applied the patch and compiled gtkdialog. Pressing the mouse
left button on the tab divider immediately highlights the
"alacarte_3.56.0-2" entry. Dragging of the divider works.
Release the mouse button and everything ok, except the menu
entry remains highlighted, and a click anywhere else outside the
menu entry causes it to be selected and the preinstall popup
appears.
Claude reply:
Thanks, that narrows it down. The popup is gone, so the
`signals.c` part works. My selection-clearing is what failed.
GTK's own handler for the end of a column resize returns TRUE,
and that stops later handlers on the signal. My `connect_after`
release handler therefore never ran.
I'll switch to a different approach that never lets the row get
selected in the first place.
I've updated the patch. It's still untested, because this
sandbox can't build against GTK.
**Why my first selection fix failed:** I tried to clear the
selection after the release. But GTK's handler for the end of a
column resize returns TRUE, which stops any handler connected
"after" it. My handler never ran, so the row stayed selected.
The stuck selection then made your next click run
`installpreview.sh` with `alacarte_3.56.0-2`.
**What the new version does** (the `signals.c` change is the
same as before):
- **Press on a divider:** if nothing is selected, the tree's
selection mode is switched to "none" before GTK's own handler
runs. GTK then has no way to select the first row, so it should
not highlight, even during the drag.
- **Release:** the original selection mode is restored. This
handler is now connected normally, not "after", so it runs
before GTK's handler can stop it.
- **A row is already selected:** nothing changes, and the
selection is kept.
To use it, apply the new patch to the original 0.8.5.1 source,
not on top of your already-patched tree. Alternatively, run
`patch -R` with the old patch first. Then rebuild.
Test the same way: press and drag the divider, release, then
click empty space. Nothing should highlight at any point, and no
popup should appear until you click a row.
If the highlight still shows up on press, please tell me whether
it's GTK 2 or GTK 3 and whether the tree is in a scrolled
window. I'd then look at where the selection is made, rather
than guess further.
There was a bit more to-and-fro after that, we ended up with two alternative fixes; patches for gtkdialog source and small change in one of the PKGget scripts.
I have implemented the fix. The latest gtkdialog will be compiled
in woofQ2.
Tags: easy