Skip to content

Commit e60568b

Browse files
author
jan
committed
#1299 refreshing the projects at startup
also boardDescriptor should not be blank/empty
1 parent 8ade60e commit e60568b

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

io.sloeber.core/src/io/sloeber/core/Activator.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.sloeber.core;
22

3+
import static org.eclipse.core.resources.IResource.*;
4+
35
import java.io.File;
46
import java.io.FileOutputStream;
57
import java.io.IOException;
@@ -10,8 +12,10 @@
1012
import org.eclipse.cdt.core.CCorePlugin;
1113
import org.eclipse.cdt.core.model.CoreModel;
1214
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
15+
import org.eclipse.core.resources.IProject;
1316
import org.eclipse.core.resources.IResourceChangeEvent;
1417
import org.eclipse.core.resources.IResourceChangeListener;
18+
import org.eclipse.core.resources.IWorkspaceRoot;
1519
import org.eclipse.core.resources.ResourcesPlugin;
1620
import org.eclipse.core.runtime.CoreException;
1721
import org.eclipse.core.runtime.IPath;
@@ -243,6 +247,19 @@ protected IStatus run(IProgressMonitor monitor) {
243247
SloeberNetworkDiscovery.start();
244248
}
245249
registerListeners();
250+
251+
// This is not installjob but to migrate 4.3 to 4.4
252+
// A refresh seems to trigger the code at a conveniant time
253+
final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
254+
for (IProject curProject : workspaceRoot.getProjects()) {
255+
if (curProject.isOpen()) {
256+
try {
257+
curProject.refreshLocal(DEPTH_INFINITE, monitor);
258+
} catch (@SuppressWarnings("unused") CoreException e) {
259+
// ignore
260+
}
261+
}
262+
}
246263
return Status.OK_STATUS;
247264
}
248265

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,10 +530,12 @@ private boolean readConfigFromCDT(ICProjectDescription prjCDesc, boolean prjDesc
530530
CompileDescription compileDescription = CompileDescription.getFromCDT(confDesc);
531531
OtherDescription otherDesc = OtherDescription.getFromCDT(confDesc);
532532
if (boardDesc.getReferencingBoardsFile() != null) {
533-
foundAValidConfig = true;
534-
myBoardDescriptions.put(getConfigKey(confDesc), boardDesc);
535-
myCompileDescriptions.put(getConfigKey(confDesc), compileDescription);
536-
myOtherDescriptions.put(getConfigKey(confDesc), otherDesc);
533+
if (!boardDesc.getReferencingBoardsFile().toString().isBlank()) {
534+
foundAValidConfig = true;
535+
myBoardDescriptions.put(getConfigKey(confDesc), boardDesc);
536+
myCompileDescriptions.put(getConfigKey(confDesc), compileDescription);
537+
myOtherDescriptions.put(getConfigKey(confDesc), otherDesc);
538+
}
537539
}
538540
}
539541
return foundAValidConfig;
@@ -725,7 +727,6 @@ private synchronized void createSloeberConfigFiles(Map<String, String> configs)
725727
myNeedToPersist = true;
726728
}
727729

728-
729730
}
730731

731732
private static void storeConfigurationFile(IFile file, Map<String, String> vars) throws Exception {

0 commit comments

Comments
 (0)