You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "mbien (via GitHub)" <gi...@apache.org> on 2023/12/01 01:40:11 UTC
[PR] Fix Project Group window EDT race condition [netbeans]
mbien opened a new pull request, #6772:
URL: https://github.com/apache/netbeans/pull/6772
The modal project-group dialog can open a modal create-group dialog as last action before it disposes. This apparently creates a race condition since the create-group dialog can receive a parent which just disappeared - leading to weird UI behavior.
`SwingUtilities.invokeLater `seems to be sufficient to make sure the first dialog is gone before the second opens so that it can get a proper parent, which is usually the main window.
+ minor cleanup
fixes #6768
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Fix Project Group window EDT race condition and update UX [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien merged PR #6772:
URL: https://github.com/apache/netbeans/pull/6772
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Fix Project Group window EDT race condition [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6772:
URL: https://github.com/apache/netbeans/pull/6772#discussion_r1416611072
##########
ide/projectui/src/org/netbeans/modules/project/ui/groups/GroupsMenu.java:
##########
@@ -137,36 +129,20 @@ private static void manageGroups() {
final JButton select = new JButton();
Mnemonics.setLocalizedText(select, GroupsMenu_manage_select_group());
select.setDefaultCapable(true);
- panel.addPropertyChangeListener(new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getPropertyName().equals("selection")) {
- select.setEnabled(panel.isExactlyOneGroupSelected());
- }
+ panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
+ if (evt.getPropertyName().equals("selection")) {
+ select.setEnabled(panel.isExactlyOneGroupSelected());
}
});
- select.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- RP.post(new Runnable() {
- @Override
- public void run() {
- Group.setActiveGroup(panel.getSelectedGroups()[0], false);
- }
- });
- }
+ select.addActionListener((ActionEvent e) -> {
+ RP.post(() -> Group.setActiveGroup(panel.getSelectedGroups()[0], false));
});
final JButton newGroup = new JButton();
newGroup.setDefaultCapable(false);
Mnemonics.setLocalizedText(newGroup, GroupsMenu_manage_new_group());
- newGroup.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- newGroup();
- }
- });
+ // invokeLater ensures that the parent is disposed before the new dialog opens
+ // so that it can set a parent which doesn't disappear - fixes race condition
+ newGroup.addActionListener(e -> SwingUtilities.invokeLater(GroupsMenu::newGroup));
Review Comment:
^ third commit changes this so that the new-group dialog opens manage-groups again
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Fix Project Group window EDT race condition [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6772:
URL: https://github.com/apache/netbeans/pull/6772#discussion_r1411513837
##########
ide/projectui/src/org/netbeans/modules/project/ui/groups/GroupsMenu.java:
##########
@@ -137,36 +129,20 @@ private static void manageGroups() {
final JButton select = new JButton();
Mnemonics.setLocalizedText(select, GroupsMenu_manage_select_group());
select.setDefaultCapable(true);
- panel.addPropertyChangeListener(new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getPropertyName().equals("selection")) {
- select.setEnabled(panel.isExactlyOneGroupSelected());
- }
+ panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
+ if (evt.getPropertyName().equals("selection")) {
+ select.setEnabled(panel.isExactlyOneGroupSelected());
}
});
- select.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- RP.post(new Runnable() {
- @Override
- public void run() {
- Group.setActiveGroup(panel.getSelectedGroups()[0], false);
- }
- });
- }
+ select.addActionListener((ActionEvent e) -> {
+ RP.post(() -> Group.setActiveGroup(panel.getSelectedGroups()[0], false));
});
final JButton newGroup = new JButton();
newGroup.setDefaultCapable(false);
Mnemonics.setLocalizedText(newGroup, GroupsMenu_manage_new_group());
- newGroup.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- newGroup();
- }
- });
+ // invokeLater ensures that the parent is disposed before the new dialog opens
+ // so that it can set a parent which doesn't disappear - fixes race condition
+ newGroup.addActionListener(e -> SwingUtilities.invokeLater(GroupsMenu::newGroup));
Review Comment:
thats the fix, rest is cleanup.
The UX is a bit weird here since creating a group closes both dialogs - what if a user wants to create a group and then switch to another group? Or create two groups?
Not closing the first dialog would require a few more updates, e.g. the list doesn't update, and UX-wise it would also be not ideal to create a group and having to press cancel to get out of the dialog (select group reloads the group).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Fix Project Group window EDT race condition and update UX [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #6772:
URL: https://github.com/apache/netbeans/pull/6772#discussion_r1416611072
##########
ide/projectui/src/org/netbeans/modules/project/ui/groups/GroupsMenu.java:
##########
@@ -137,36 +129,20 @@ private static void manageGroups() {
final JButton select = new JButton();
Mnemonics.setLocalizedText(select, GroupsMenu_manage_select_group());
select.setDefaultCapable(true);
- panel.addPropertyChangeListener(new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getPropertyName().equals("selection")) {
- select.setEnabled(panel.isExactlyOneGroupSelected());
- }
+ panel.addPropertyChangeListener((PropertyChangeEvent evt) -> {
+ if (evt.getPropertyName().equals("selection")) {
+ select.setEnabled(panel.isExactlyOneGroupSelected());
}
});
- select.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- RP.post(new Runnable() {
- @Override
- public void run() {
- Group.setActiveGroup(panel.getSelectedGroups()[0], false);
- }
- });
- }
+ select.addActionListener((ActionEvent e) -> {
+ RP.post(() -> Group.setActiveGroup(panel.getSelectedGroups()[0], false));
});
final JButton newGroup = new JButton();
newGroup.setDefaultCapable(false);
Mnemonics.setLocalizedText(newGroup, GroupsMenu_manage_new_group());
- newGroup.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- newGroup();
- }
- });
+ // invokeLater ensures that the parent is disposed before the new dialog opens
+ // so that it can set a parent which doesn't disappear - fixes race condition
+ newGroup.addActionListener(e -> SwingUtilities.invokeLater(GroupsMenu::newGroup));
Review Comment:
^ third commit changes this so that the new-group dialog opens manage-groups again
oops, I almost added the same race condition again, fixed :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists