Changeset 17423 in josm


Ignore:
Timestamp:
2020-12-22T09:28:39+01:00 (2 months ago)
Author:
GerdP
Message:

see #20228: JOSM hangs when downloading children relations

  • partly revert r17206 (don't wait) , this should fix the hanging situation
  • register / unregister listeners to avoid EDT violations when relation editor doesn't show the "Tags and Members" dialog tab
Location:
trunk/src/org/openstreetmap/josm/gui/dialogs/relation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java

    r17358 r17423  
    66
    77import java.awt.BorderLayout;
     8import java.awt.Component;
    89import java.awt.Dimension;
    910import java.awt.FlowLayout;
     
    170171    private final ArrayList<FlavorListener> clipboardListeners = new ArrayList<>();
    171172
     173    private Component selectedTabPane;
     174    private JTabbedPane tabbedPane;
     175
    172176    /**
    173177     * Creates a new relation editor for the given relation. The relation will be saved if the user
     
    236240
    237241        getContentPane().setLayout(new BorderLayout());
    238         JTabbedPane tabbedPane = new JTabbedPane();
     242        tabbedPane = new JTabbedPane();
    239243        tabbedPane.add(tr("Tags and Members"), pnl);
    240244        referrerBrowser = new ReferringRelationsBrowser(getLayer(), referrerModel);
    241245        tabbedPane.add(tr("Parent Relations"), referrerBrowser);
    242246        tabbedPane.add(tr("Child Relations"), new ChildRelationBrowser(getLayer(), relation));
     247        selectedTabPane = tabbedPane.getSelectedComponent();
    243248        tabbedPane.addChangeListener(e -> {
    244249            JTabbedPane sourceTabbedPane = (JTabbedPane) e.getSource();
     
    248253                referrerBrowser.init();
    249254            }
     255            // see #20228
     256            boolean selIsTagsAndMembers = sourceTabbedPane.getSelectedComponent() == pnl;
     257            if (selectedTabPane == pnl && !selIsTagsAndMembers) {
     258                unregisterMain();
     259            } else if (selectedTabPane != pnl && selIsTagsAndMembers) {
     260                registerMain();
     261            }
     262            selectedTabPane = sourceTabbedPane.getSelectedComponent();
    250263        });
    251264
     
    313326        HelpUtil.setHelpContext(getRootPane(), ht("/Dialog/RelationEditor"));
    314327        UndoRedoHandler.getInstance().addCommandQueueListener(this);
     328    }
     329
     330    private void registerMain() {
     331        selectionTableModel.register();
     332        memberTableModel.register();
     333        memberTable.registerListeners();
     334    }
     335
     336    private void unregisterMain() {
     337        selectionTableModel.unregister();
     338        memberTableModel.unregister();
     339        memberTable.unregisterListeners();
    315340    }
    316341
     
    733758            //
    734759            memberTable.stopHighlighting();
    735             selectionTableModel.unregister();
    736             memberTableModel.unregister();
    737             memberTable.unregisterListeners();
     760            if (tabbedPane != null && tr("Tags and Members").equals(tabbedPane.getTitleAt(tabbedPane.getSelectedIndex()))) {
     761                unregisterMain();
     762            }
    738763            if (windowMenuItem != null) {
    739764                MainApplication.getMenu().windowMenu.remove(windowMenuItem);
     
    841866        UndoRedoHandler.getInstance().removeCommandQueueListener(this);
    842867        setRelation(null);
     868        selectedTabPane = null;
    843869        super.dispose();
    844870    }
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java

    r17217 r17423  
    134134        // just trigger a repaint - the display name of the relation members may have changed
    135135        Collection<RelationMember> sel = getSelectedMembers();
    136         GuiHelper.runInEDTAndWait(this::fireTableDataChanged);
     136        GuiHelper.runInEDT(this::fireTableDataChanged);
    137137        setSelectedMembers(sel);
    138138    }
Note: See TracChangeset for help on using the changeset viewer.