-
Notifications
You must be signed in to change notification settings - Fork 162
[Gtk3] fix for SWTException on Table.remove(...) with focused row #1606 #1608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
om-11-2024
wants to merge
1
commit into
eclipse-platform:master
Choose a base branch
from
om-11-2024:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
...t.tests.gtk/JUnit Tests/org/eclipse/swt/tests/gtk/Test_Gtk3_Table_Remove_Focused_Row.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.eclipse.swt.tests.gtk; | ||
|
||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.internal.gtk.GTK; | ||
import org.eclipse.swt.layout.FillLayout; | ||
import org.eclipse.swt.widgets.Shell; | ||
import org.eclipse.swt.widgets.Table; | ||
import org.eclipse.swt.widgets.TableItem; | ||
import org.junit.After; | ||
import org.junit.Assume; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
public class Test_Gtk3_Table_Remove_Focused_Row { | ||
|
||
private Shell shell; | ||
private Table table; | ||
|
||
@BeforeClass | ||
public static void setUpClass() { | ||
var isGtk3 = false; | ||
if ("gtk".equals(SWT.getPlatform())) { | ||
@SuppressWarnings("restriction") | ||
var gtkMajorVersion = GTK.GTK_VERSION >>> 16; | ||
isGtk3 = (gtkMajorVersion == 3); | ||
} | ||
Assume.assumeTrue("Test is only for Gtk3.", isGtk3); | ||
} | ||
|
||
@Before | ||
public void setUp() { | ||
shell = new Shell(); | ||
shell.setMinimumSize(400, 400); | ||
shell.setLayout(new FillLayout()); | ||
} | ||
|
||
@After | ||
public void tearDown() { | ||
if (table != null) { | ||
table.dispose(); | ||
} | ||
if (shell != null) { | ||
shell.dispose(); | ||
} | ||
} | ||
|
||
@Test | ||
public void test_remove_focused_row_remove_one() { | ||
test_remove_focused_row_remove_method_arg(() -> table.remove(0)); | ||
} | ||
|
||
@Test | ||
public void test_remove_focused_row_remove_array() { | ||
test_remove_focused_row_remove_method_arg(() -> table.remove(new int[] { 0 })); | ||
} | ||
|
||
@Test | ||
public void test_remove_focused_row_remove_interval() { | ||
test_remove_focused_row_remove_method_arg(() -> table.remove(0, 0)); | ||
} | ||
|
||
private void test_remove_focused_row_remove_method_arg(Runnable removeRow0) { | ||
table = new Table(shell, SWT.VIRTUAL); | ||
table.setItemCount(2); | ||
table.addListener(SWT.SetData, event -> { | ||
var item = (TableItem) event.item; | ||
item.setText("Item #" + System.identityHashCode(item) + " " + item.toString()); | ||
}); | ||
|
||
shell.pack(); | ||
shell.open(); | ||
|
||
processUiEvents(); | ||
|
||
// set focus on row[0] | ||
table.setFocus(); | ||
|
||
processUiEvents(); | ||
|
||
table.clear(0); | ||
removeRow0.run(); | ||
|
||
processUiEvents(); | ||
} | ||
|
||
private void processUiEvents() { | ||
while (table.getDisplay().readAndDispatch()) { | ||
// continue to next event | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this test fail on other platforms? If not, why should not it run there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The platform (as returned by
org.eclipse.swt.SWT.getPlatform()
) is "gtk".All the test in
tests/gtk/...
are executed only on "gtk" platform.This test is in
tests/gtk/...
because it tests a bug in the swt implementation for gtk.For now swt uses gtk3 + switching to gtk4 is in progress.
In gtk4
GtkTreeView
is deprecated, which means that the code forTable
for gtk4 will be rewritten.That's why this test and this fix are only for gtk3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additionally.
In GTK3 this bug involves
GtkCellAccessible
from the so called Accessibility toolkit (ATK) used by GTK3.In GTK4 accessibility implemented differently and ATK isn't used anymore.
As a result, even if SWT would continue to use deprecated
GtkTreeView
in GTK4, this bug would not happen there.