1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-18 07:52:14 +01:00

Fix rebuild being triggered on every menu open()

Fixes #7924

JRE 8u161 made JMenu.insert() MUCH slower on OSX.
This exposed a bug lurking there for years; in fact the menu entries were rebuilt every time since JMenu.getComponent() returns an empty list.
The correct function is JMenu.getMenuComponents().
In the meantime, also remove sketchbookMenu and examplesMenu being deleted on board change; only their content needs to be updated, not the container itself.
This commit is contained in:
Martino Facchin 2018-08-27 16:20:45 +02:00
parent 49cd9b57dd
commit 2f3a561c61

View File

@ -262,8 +262,6 @@ public class Editor extends JFrame implements RunnerListener {
// added for 1.0.5
// http://dev.processing.org/bugs/show_bug.cgi?id=1260
public void windowDeactivated(WindowEvent e) {
fileMenu.remove(sketchbookMenu);
fileMenu.remove(examplesMenu);
List<Component> toolsMenuItemsToRemove = new LinkedList<>();
for (Component menuItem : toolsMenu.getMenuComponents()) {
if (menuItem instanceof JComponent) {
@ -504,7 +502,7 @@ public class Editor extends JFrame implements RunnerListener {
fileMenu.addMenuListener(new StubMenuListener() {
@Override
public void menuSelected(MenuEvent e) {
List<Component> components = Arrays.asList(fileMenu.getComponents());
List<Component> components = Arrays.asList(fileMenu.getMenuComponents());
if (!components.contains(sketchbookMenu)) {
fileMenu.insert(sketchbookMenu, 3);
}
@ -537,7 +535,7 @@ public class Editor extends JFrame implements RunnerListener {
toolsMenu.addMenuListener(new StubMenuListener() {
@Override
public void menuSelected(MenuEvent e) {
List<Component> components = Arrays.asList(toolsMenu.getComponents());
List<Component> components = Arrays.asList(toolsMenu.getMenuComponents());
int offset = 0;
for (JMenu menu : base.getBoardsCustomMenus()) {
if (!components.contains(menu)) {