From e360f82cae38254d9e299db5e66e4fdbbe074bc1 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Tue, 27 Jan 2015 20:22:22 +0100 Subject: [PATCH] Fixed incorrect boards.txt preference handling when submenu id has underscore Fixes #2533 --- .../src/processing/app/BaseNoGui.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/arduino-core/src/processing/app/BaseNoGui.java b/arduino-core/src/processing/app/BaseNoGui.java index 2eff168a74..ee1b1d0a69 100644 --- a/arduino-core/src/processing/app/BaseNoGui.java +++ b/arduino-core/src/processing/app/BaseNoGui.java @@ -154,18 +154,27 @@ static public PreferencesMap getBoardPreferences() { TargetBoard board = getTargetBoard(); if (board == null) return null; + String boardId = board.getId(); PreferencesMap prefs = new PreferencesMap(board.getPreferences()); + + String extendedName = prefs.get("name"); for (String menuId : board.getMenuIds()) { + if (!board.hasMenu(menuId)) + continue; + + // Get "custom_[MENU_ID]" preference (for example "custom_cpu") String entry = PreferencesData.get("custom_" + menuId); - if (board.hasMenu(menuId) && entry != null && - entry.startsWith(board.getId())) { - String selectionId = entry.substring(entry.indexOf("_") + 1); + if (entry != null && entry.startsWith(boardId)) { + + String selectionId = entry.substring(boardId.length() + 1); prefs.putAll(board.getMenuPreferences(menuId, selectionId)); - prefs.put("name", prefs.get("name") + ", " + - board.getMenuLabel(menuId, selectionId)); + + // Update the name with the extended configuration + extendedName += ", " + board.getMenuLabel(menuId, selectionId); } } + prefs.put("name", extendedName); return prefs; }