[Gtk3] fix for SWTException on Table.remove(...) with focused row #1606 #1608
+104
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix for
SWTException
onTable.remove(...)
with a focused row.Cause:
gtk_list_store_remove(...)
for a focused row invokesTable.cellDataProc(...)
with not-yet-updatedTable.items
.Fix: remove
TableItem
fromTable.items
beforegtk_list_store_remove(...)
.Fixes #1606
This bug happens in Gtk3.
I haven't tried to reproduce this bug in GTK4.
Java stacktrace:
The main cause of the error is that:
gtk_list_store_remove(...)
, then cell data functionTable.cellDataProc(...)
is called for a row after the removed oneTable.cellDataProc(...)
Table.items
isn't yet updated , thereforeTable.cellDataProc(...)
operates withTableItem
, which is already disposed but not yet removed fromTable.items
Inside
gtk_list_store_remove(...)
the row is removed from theGtkTreeModel
, and only thenGtkTreeView
callbacks are invoked. It means that whenTable.cellDataProc(...)
is invoked, the row has already been removed in Gtk3.The fix: remove
TableItem
fromTable.items
beforegtk_list_store_remove(...)
instead of after.Os: Ubuntu 24.04.1 LTS
Gtk: 3.24.41
Swt: 4.967.8
=================================================
Why
gtk_list_store_remove(...)
invokesTable.cellDataProc(...)
only for a row with focus and not for ordinary rows?The reason is that in gtk3 when a row with focus is deleted, the next row receives focus, which among other things creates
GtkCellAccessible
(a "cell with focus" for assistive technology in gtk3).Creation of
GtkCellAccessible
invokes cell data functionTable.cellDataProc(...)
- just like it happens when a standard cell inGtkTreeView
gets rendered.Here is the stacktrace in gtk3 code:
The code that leads to execution of cell data function for a row with focus is in gtktreeview.c: