Skip to content

Commit fa47c64

Browse files
Remove recentBoardsToClear
Instead, just remove items until the separator.
1 parent a9631da commit fa47c64

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

app/src/processing/app/Base.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public class Base {
125125
// these variables help rebuild the "recently used boards"
126126
// menu on board selection
127127
private HashMap<String, JRadioButtonMenuItem> boardItems;
128-
private List<JRadioButtonMenuItem> recentBoardsToClear = new LinkedList<>();;
129128
private JMenu boardMenu;
130129
private int recentBoardsJMenuIndex;
131130

@@ -1620,16 +1619,15 @@ private void rebuildRecentBoardsList() throws Exception {
16201619
Collection<String> recentBoardIds = PreferencesData.getCollection("recent.boards");
16211620
String currentBoard = PreferencesData.get("board");
16221621
int idxAdv = 0;
1623-
for (JRadioButtonMenuItem itemToClear : recentBoardsToClear) {
1624-
boardMenu.remove(itemToClear);
1622+
// Remove existing items until the separator
1623+
while (!(boardMenu.getMenuComponent(recentBoardsJMenuIndex) instanceof JSeparator)) {
1624+
boardMenu.remove(recentBoardsJMenuIndex);
16251625
}
1626-
recentBoardsToClear.clear();
16271626
for (String boardId : recentBoardIds) {
16281627
JRadioButtonMenuItem originalItem = boardItems.get(boardId);
16291628
JRadioButtonMenuItem recentItem = new JRadioButtonMenuItem(originalItem.getAction());
16301629

16311630
boardMenu.add(recentItem, recentBoardsJMenuIndex+idxAdv);
1632-
recentBoardsToClear.add(recentItem);
16331631
recentItem.setSelected(boardId.equals(currentBoard));
16341632
idxAdv++;
16351633
}

0 commit comments

Comments
 (0)