@@ -66,7 +66,8 @@ public class BoardDescription {
6666 private String myProgrammer = EMPTY ;
6767 private String myBoardID = EMPTY ;
6868 private Map <String , String > myOptions = new TreeMap <>(String .CASE_INSENSITIVE_ORDER );
69- private BoardTxtFile myBoardTxtFile ;
69+ private File myUserSelectedBoardsTxtFile ; //this is the boards.txt file selected in the gui
70+ private BoardTxtFile mySloeberBoardTxtFile ; // this is the actual used and loaded sloeber.boards.txt file
7071
7172 private String myBoardsCore = null ;
7273 private String myBoardsVariant = null ;
@@ -149,7 +150,7 @@ private void calculateDerivedFields() {
149150 }
150151
151152 private void ParseSection () {
152- KeyValueTree rootData = myBoardTxtFile .getData ();
153+ KeyValueTree rootData = mySloeberBoardTxtFile .getData ();
153154 String boardID = getBoardID ();
154155 KeyValueTree boardData = rootData .getChild (boardID );
155156
@@ -301,23 +302,25 @@ public static List<BoardDescription> makeBoardDescriptors(File boardFile) {
301302 */
302303 BoardDescription (File boardsFile , String boardID , Map <String , String > options ) {
303304 myBoardID = boardID ;
304- myBoardTxtFile = new BoardTxtFile (resolvePathEnvironmentString (boardsFile ));
305+ myUserSelectedBoardsTxtFile = boardsFile ;
306+ mySloeberBoardTxtFile = new BoardTxtFile (resolvePathEnvironmentString (myUserSelectedBoardsTxtFile ));
305307 setDefaultOptions ();
306308 if (options != null ) {
307309 myOptions .putAll (options );
308310 }
309311 }
310312
311313 public BoardDescription () {
312- File boardsFile = new File (myStorageNode .get (KEY_LAST_USED_BOARDS_FILE , EMPTY ));
313- if (!boardsFile .exists ()) {
314+ myUserSelectedBoardsTxtFile = new File (myStorageNode .get (KEY_LAST_USED_BOARDS_FILE , EMPTY ));
315+ if (!myUserSelectedBoardsTxtFile .exists ()) {
314316 List <ArduinoPlatformVersion > platforms = BoardsManager .getInstalledPlatforms ();
315317 //If you crash on the next line no platform have been installed
316318 ArduinoPlatformVersion platform = platforms .get (0 );
317- myBoardTxtFile = new BoardTxtFile (platform .getBoardsFile ());
318- myBoardID = myBoardTxtFile .getAllBoardIDs ().get (0 );
319+ myUserSelectedBoardsTxtFile = platform .getBoardsFile ();
320+ mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
321+ myBoardID = mySloeberBoardTxtFile .getAllBoardIDs ().get (0 );
319322 } else {
320- myBoardTxtFile = new BoardTxtFile (boardsFile );
323+ mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
321324 myBoardID = myStorageNode .get (KEY_LAST_USED_BOARD , EMPTY );
322325 myUploadPort = myStorageNode .get (KEY_LAST_USED_UPLOAD_PORT , EMPTY );
323326 myProgrammer = myStorageNode .get (KEY_LAST_USED_UPLOAD_PROTOCOL , EMPTY );
@@ -326,7 +329,8 @@ public BoardDescription() {
326329 }
327330
328331 public BoardDescription (BoardDescription srcObject ) {
329- myBoardTxtFile = srcObject .myBoardTxtFile ;
332+ myUserSelectedBoardsTxtFile = srcObject .myUserSelectedBoardsTxtFile ;
333+ mySloeberBoardTxtFile = srcObject .mySloeberBoardTxtFile ;
330334 myBoardID = srcObject .myBoardID ;
331335 myUploadPort = srcObject .myUploadPort ;
332336 myProgrammer = srcObject .myProgrammer ;
@@ -345,10 +349,10 @@ public String getuploadTool() {
345349 * incomplete or invalid this method still returns a complete and valid set.
346350 */
347351 private void setDefaultOptions () {
348- Map <String , String > allMenuIDs = this .myBoardTxtFile .getMenus ();
352+ Map <String , String > allMenuIDs = this .mySloeberBoardTxtFile .getMenus ();
349353 for (Map .Entry <String , String > curMenuID : allMenuIDs .entrySet ()) {
350354 String providedMenuValue = this .myOptions .get (curMenuID .getKey ());
351- ArrayList <String > menuOptions = this .myBoardTxtFile .getMenuItemIDsFromMenuID (curMenuID .getKey (),
355+ ArrayList <String > menuOptions = this .mySloeberBoardTxtFile .getMenuItemIDsFromMenuID (curMenuID .getKey (),
352356 getBoardID ());
353357 if (menuOptions .size () > 0 ) {
354358 if (providedMenuValue == null ) {
@@ -374,15 +378,15 @@ public void saveUserSelection() {
374378 }
375379
376380 public String getArchitecture () {
377- return myBoardTxtFile .getArchitecture ();
381+ return mySloeberBoardTxtFile .getArchitecture ();
378382 }
379383
380384 public File getReferencingBoardsFile () {
381- return myBoardTxtFile . getLoadedFile () ;
385+ return myUserSelectedBoardsTxtFile ;
382386 }
383387
384388 public String getBoardName () {
385- return this .myBoardTxtFile .getNiceNameFromID (this .myBoardID );
389+ return this .mySloeberBoardTxtFile .getNiceNameFromID (this .myBoardID );
386390 }
387391
388392 public String getUploadPort () {
@@ -431,7 +435,7 @@ private void setDirty() {
431435 }
432436
433437 public void setBoardName (String boardName ) {
434- String newBoardID = this .myBoardTxtFile .getIDFromNiceName (boardName );
438+ String newBoardID = this .mySloeberBoardTxtFile .getIDFromNiceName (boardName );
435439 if ((newBoardID == null || this .myBoardID .equals (newBoardID ))) {
436440 return ;
437441 }
@@ -444,14 +448,15 @@ public void setreferencingBoardsFile(File boardsFile) {
444448 if (boardsFile == null ) {
445449 return ;// ignore
446450 }
447- /*
448- * do not do this optimization as workaround changes will not be captured if
449- * (this.myreferencingBoardsFile.equals(resolvePathEnvironmentString(boardsFile)
450- * )) { return; }
451- */
452451
453- myBoardTxtFile = new BoardTxtFile (resolvePathEnvironmentString (boardsFile ));
454- setDirty ();
452+ if (!myUserSelectedBoardsTxtFile .equals (boardsFile )) {
453+ myUserSelectedBoardsTxtFile = boardsFile ;
454+ setDirty ();
455+ }
456+
457+ /* do not remove this for optimization as workaround changes will not be captured */
458+ mySloeberBoardTxtFile = new BoardTxtFile (resolvePathEnvironmentString (myUserSelectedBoardsTxtFile ));
459+
455460 }
456461
457462 public void setOptions (Map <String , String > options ) {
@@ -486,7 +491,7 @@ public String getBoardID() {
486491 }
487492
488493 public String [] getCompatibleBoards () {
489- return this .myBoardTxtFile .getAllSectionNames ();
494+ return this .mySloeberBoardTxtFile .getAllSectionNames ();
490495 }
491496
492497 public String [] getUploadProtocols () {
@@ -496,7 +501,7 @@ public String[] getUploadProtocols() {
496501 }
497502
498503 public String [] getMenuItemNamesFromMenuID (String menuID ) {
499- return this .myBoardTxtFile .getMenuItemNamesFromMenuID (menuID , this .myBoardID );
504+ return this .mySloeberBoardTxtFile .getMenuItemNamesFromMenuID (menuID , this .myBoardID );
500505 }
501506
502507 public TreeMap <String , IPath > getAllExamples () {
@@ -505,15 +510,15 @@ public TreeMap<String, IPath> getAllExamples() {
505510 }
506511
507512 public String getMenuNameFromMenuID (String id ) {
508- return this .myBoardTxtFile .getMenuNameFromID (id );
513+ return this .mySloeberBoardTxtFile .getMenuNameFromID (id );
509514 }
510515
511516 public String getMenuItemNamedFromMenuItemID (String menuItemID , String menuID ) {
512- return this .myBoardTxtFile .getMenuItemNameFromMenuItemID (this .myBoardID , menuID , menuItemID );
517+ return this .mySloeberBoardTxtFile .getMenuItemNameFromMenuItemID (this .myBoardID , menuID , menuItemID );
513518 }
514519
515520 public String getMenuItemIDFromMenuItemName (String menuItemName , String menuID ) {
516- return this .myBoardTxtFile .getMenuItemIDFromMenuItemName (this .myBoardID , menuID , menuItemName );
521+ return this .mySloeberBoardTxtFile .getMenuItemIDFromMenuItemName (this .myBoardID , menuID , menuItemName );
517522 }
518523
519524 /**
@@ -529,7 +534,7 @@ public IPath getActualVariantPath() {
529534 return null ;
530535 }
531536 if (myReferencedPlatformVariant == null ) {
532- return new Path (myBoardTxtFile . getLoadedFile () .getParent ().toString ()).append (VARIANTS_FOLDER_NAME )
537+ return new Path (myUserSelectedBoardsTxtFile .getParent ().toString ()).append (VARIANTS_FOLDER_NAME )
533538 .append (boardVariant );
534539 }
535540 return myReferencedPlatformVariant .getInstallPath ().append (VARIANTS_FOLDER_NAME ).append (boardVariant );
@@ -573,7 +578,7 @@ public PlatformTxtFile getReferencingPlatformFile() {
573578
574579 public Path getreferencingPlatformPath () {
575580 try {
576- return new Path (myBoardTxtFile . getLoadedFile () .getParent ());
581+ return new Path (myUserSelectedBoardsTxtFile .getParent ());
577582 } catch (@ SuppressWarnings ("unused" ) Exception e ) {
578583 return new Path (EMPTY );
579584 }
@@ -617,7 +622,7 @@ public String getUploadPatternKey() {
617622 public IPath getreferencedCoreHardwarePath () {
618623 updateWhenDirty ();
619624 if (myReferencedPlatformCore == null ) {
620- return new Path ( myBoardTxtFile . getLoadedFile (). toString ()). removeLastSegments ( 1 );
625+ return getreferencingPlatformPath ( );
621626 }
622627 return myReferencedPlatformCore .getInstallPath ();
623628 }
@@ -663,9 +668,10 @@ public boolean isNetworkUpload() {
663668 return getHost () != null ;
664669 }
665670
666- protected BoardDescription (File txtFile , String boardID ) {
671+ protected BoardDescription (File boardsFile , String boardID ) {
667672 myBoardID = boardID ;
668- myBoardTxtFile = new BoardTxtFile (txtFile );
673+ myUserSelectedBoardsTxtFile = boardsFile ;
674+ mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
669675 setDefaultOptions ();
670676 calculateDerivedFields ();
671677 }
@@ -681,8 +687,8 @@ protected BoardDescription(File txtFile, String boardID) {
681687 KeyValueTree optionsTree = section .getChild (KEY_SLOEBER_MENU_SELECTION );
682688 Map <String , String > options = optionsTree .toKeyValues (EMPTY , false );
683689
684- File ResolvedFile = resolvePathEnvironmentString (new File (board_txt ));
685- myBoardTxtFile = new BoardTxtFile (ResolvedFile );
690+ myUserSelectedBoardsTxtFile = resolvePathEnvironmentString (new File (board_txt ));
691+ mySloeberBoardTxtFile = new BoardTxtFile (myUserSelectedBoardsTxtFile );
686692 setDefaultOptions ();
687693 if (options != null ) {
688694 // Only add the valid options for this board to our options
@@ -693,7 +699,7 @@ protected BoardDescription(File txtFile, String boardID) {
693699 private Map <String , String > onlyKeepValidOptions (Map <String , String > options ) {
694700 Map <String , String > ret = new HashMap <>();
695701
696- KeyValueTree tree = myBoardTxtFile .getData ();
702+ KeyValueTree tree = mySloeberBoardTxtFile .getData ();
697703 KeyValueTree boardMenuSection = tree .getChild (myBoardID + DOT + MENU );
698704 if (boardMenuSection != null ) {
699705 for (Entry <String , String > curoption : options .entrySet ()) {
@@ -816,11 +822,11 @@ public Map<String, String> getEnvVars() {
816822 allVars .putAll (getEnVarPlatformInfo ());
817823
818824 // boards settings not coming from menu selections
819- allVars .putAll (myBoardTxtFile .getBoardEnvironVars (getBoardID ()));
825+ allVars .putAll (mySloeberBoardTxtFile .getBoardEnvironVars (getBoardID ()));
820826
821827 // board settings from menu selections
822828 Map <String , String > options = getOptions ();
823- KeyValueTree rootData = myBoardTxtFile .getData ();
829+ KeyValueTree rootData = mySloeberBoardTxtFile .getData ();
824830 KeyValueTree menuData = rootData .getChild (getBoardID () + DOT + MENU );
825831 for (Entry <String , String > curOption : options .entrySet ()) {
826832 String menuID = curOption .getKey ();
@@ -1076,27 +1082,30 @@ public static BoardDescription getFromCDT(ICConfigurationDescription confDesc) {
10761082 if (packagesIndex != -1 ) {
10771083 referencingBoardsFile = sloeberHomePath .append (referencingBoardsFile .substring (packagesIndex )).toString ();
10781084 }
1079- File resolvedFile = resolvePathEnvironmentString (new File (referencingBoardsFile ));
1080- ret .myBoardTxtFile = new BoardTxtFile (resolvedFile );
1085+ ret . myUserSelectedBoardsTxtFile = resolvePathEnvironmentString (new File (referencingBoardsFile ));
1086+ ret .mySloeberBoardTxtFile = new BoardTxtFile (ret . myUserSelectedBoardsTxtFile );
10811087
10821088 return ret ;
10831089 }
10841090
10851091 public boolean isValid () {
1086- File boardsFile = myBoardTxtFile .getLoadedFile ();
1092+ if (!myUserSelectedBoardsTxtFile .exists ()) {
1093+ return false ;
1094+ }
1095+ File boardsFile = mySloeberBoardTxtFile .getLoadedFile ();
10871096 if (boardsFile == null ) {
10881097 return false ;
10891098 }
10901099 return boardsFile .exists ();
10911100 }
10921101
10931102 public void reloadTxtFile () {
1094- myBoardTxtFile .reloadTxtFile ();
1103+ mySloeberBoardTxtFile .reloadTxtFile ();
10951104
10961105 }
10971106
10981107 public Map <String , String > getAllMenus () {
1099- return myBoardTxtFile .getMenus ();
1108+ return mySloeberBoardTxtFile .getMenus ();
11001109 }
11011110
11021111 public boolean isSSHUpload () {
0 commit comments