Skip to content

Commit 36cbe55

Browse files
author
jantje
committed
#1347 this fixed my upgrade test; hopefully no regression elsewhere
1 parent 72c4cf8 commit 36cbe55

File tree

1 file changed

+39
-32
lines changed

1 file changed

+39
-32
lines changed

io.sloeber.core/src/io/sloeber/core/api/SloeberProject.java

+39-32
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public class SloeberProject extends Common {
6868
private boolean myNeedToPersist = false; // Do we need to write data to disk
6969
private boolean myNeedsClean = false; // is there old sloeber data that needs cleaning
7070
private boolean myNeedsSyncWithCDT = false; // Knows CDT all configs Sloeber Knows
71+
private boolean myIsConfiguring = false; // True if configuration of the project is ongoing
7172

7273
private static final String ENV_KEY_BUILD_SOURCE_PATH = BUILD + DOT + SOURCE + DOT + PATH;
7374
private static final String ENV_KEY_BUILD_PATH = BUILD + DOT + PATH;
@@ -394,47 +395,56 @@ public void configure() {
394395
*/
395396

396397
public synchronized boolean configure(ICProjectDescription prjCDesc, boolean prjDescWritable) {
398+
if (myIsConfiguring) {
399+
return false;
400+
}
397401
boolean saveProjDesc = false;
398-
if (isInMemory) {
399-
if (myIsDirty) {
400-
createSloeberConfigFiles(prjCDesc);
401-
setAllEnvironmentVars(prjCDesc);
402402

403-
myIsDirty = false;
403+
try {
404+
myIsConfiguring = true;
405+
406+
if (isInMemory) {
407+
if (myIsDirty) {
408+
createSloeberConfigFiles(prjCDesc);
409+
setAllEnvironmentVars(prjCDesc);
410+
myIsDirty = false;
411+
}
412+
if (myNeedToPersist) {
413+
createSloeberConfigFiles(prjCDesc);
414+
}
415+
if (prjDescWritable) {
416+
if (myNeedsSyncWithCDT) {
417+
saveProjDesc = saveProjDesc || syncWithCDT(prjCDesc, prjDescWritable);
418+
}
419+
if (myNeedsClean) {
420+
myNeedsClean = cleanOldData(prjCDesc);
421+
saveProjDesc = saveProjDesc || myNeedsClean;
422+
}
423+
}
424+
return saveProjDesc;
404425
}
405-
if (myNeedToPersist) {
426+
427+
// first read the sloeber files in memory
428+
saveProjDesc = readConfig(prjCDesc, prjDescWritable);
429+
if (myNeedToPersist || myIsDirty) {
406430
createSloeberConfigFiles(prjCDesc);
431+
myIsDirty = false;
407432
}
408433
if (prjDescWritable) {
409-
if (myNeedsSyncWithCDT) {
410-
saveProjDesc = saveProjDesc || syncWithCDT(prjCDesc, prjDescWritable);
411-
}
412434
if (myNeedsClean) {
435+
// we migrated from a previous sloeber configuration
436+
// and we can safely delete the old data
413437
myNeedsClean = cleanOldData(prjCDesc);
414438
saveProjDesc = saveProjDesc || myNeedsClean;
415439
}
440+
if (myNeedsSyncWithCDT) {
441+
saveProjDesc = saveProjDesc || syncWithCDT(prjCDesc, prjDescWritable);
442+
}
416443
}
417-
return saveProjDesc;
418-
}
419-
420-
// first read the sloeber files in memory
421-
saveProjDesc = readConfig(prjCDesc, prjDescWritable);
422-
if (myNeedToPersist || myIsDirty) {
423-
createSloeberConfigFiles(prjCDesc);
424-
myIsDirty = false;
425-
}
426-
if (prjDescWritable) {
427-
if (myNeedsClean) {
428-
// we migrated from a previous sloeber configuration
429-
// and we can safely delete the old data
430-
myNeedsClean = cleanOldData(prjCDesc);
431-
saveProjDesc = saveProjDesc || myNeedsClean;
432-
}
433-
if (myNeedsSyncWithCDT) {
434-
saveProjDesc = saveProjDesc || syncWithCDT(prjCDesc, prjDescWritable);
435-
}
444+
setAllEnvironmentVars(prjCDesc);
445+
} finally {
446+
myIsConfiguring = false;
436447
}
437-
setAllEnvironmentVars(prjCDesc);
438448
return saveProjDesc;
439449
}
440450

@@ -660,7 +670,6 @@ public void run(IProgressMonitor internalMonitor) throws CoreException {
660670
return runnable.projConfMustBeSaved;
661671
}
662672

663-
664673
/**
665674
* This methods creates/updates 2 files in the workspace. Together these files
666675
* contain the Sloeber project configuration info The info is split into 2 files
@@ -785,8 +794,6 @@ public void setBoardDescription(String confDescName, BoardDescription boardDescr
785794
myIsDirty = true;
786795
}
787796

788-
789-
790797
/**
791798
* get the Arduino project description based on a project description
792799
*

0 commit comments

Comments
 (0)