Skip to content

Commit 7604099

Browse files
author
jantje
committed
for issue #362. When renaming the last .ino to .cpp the indexer hangs
The root cause was that due to a return statement the indexer lock was not released
1 parent 151e76e commit 7604099

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

it.baeyens.arduino.core/src/it/baeyens/arduino/tools/PdePreprocessor.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,15 @@ public static void processProject(IProject iProject) throws CoreException {
6161
header += NEWLINE;
6262
ICProject tt = CoreModel.getDefault().create(iProject);
6363
IIndex index = CCorePlugin.getIndexManager().getIndex(tt);
64+
6465
try {
65-
index.acquireReadLock();
66+
try {
67+
index.acquireReadLock();
68+
} catch (InterruptedException e) {
69+
// TODO Auto-generated catch block
70+
e.printStackTrace();
71+
return;
72+
}
6673

6774
// take all the files in the project
6875
IResource allResources[] = iProject.members(0);// .getFolder("").members(0);
@@ -144,17 +151,15 @@ public static void processProject(IProject iProject) throws CoreException {
144151
if (inofile != null) {
145152
inofile.delete(true, null);
146153
}
147-
return;
154+
} else {
155+
// concatenate the parts and make the .ino.cpp file
156+
String output = header + includeHeaderPart + body + includeCodePart;
157+
Helpers.addFileToProject(iProject, new Path(tempFile), new ByteArrayInputStream(output.getBytes()),
158+
null);
148159
}
149160

150-
// concatenate the parts and make the .ino.cpp file
151-
String output = header + includeHeaderPart + body + includeCodePart;
152-
Helpers.addFileToProject(iProject, new Path(tempFile), new ByteArrayInputStream(output.getBytes()),
153-
null);
161+
} finally {
154162
index.releaseReadLock();
155-
} catch (InterruptedException e) {
156-
// TODO Auto-generated catch block
157-
e.printStackTrace();
158163
}
159164
}
160165
}

0 commit comments

Comments
 (0)