Skip to content

Commit 9b60203

Browse files
EcljpseB0Tiloveeclipse
authored andcommitted
fix StatusLine progress
Reusing a monitor received from IStatusLineManager requires to finally call progressMonitor.done() before using it again. see https://bugs.eclipse.org/bugs/show_bug.cgi?id=485748 and eclipse-jdt/eclipse.jdt.ui#773
1 parent 8333d0b commit 9b60203

File tree

1 file changed

+59
-26
lines changed

1 file changed

+59
-26
lines changed

bundles/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java

Lines changed: 59 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -557,29 +557,36 @@ protected FileInfo createFileInfo(Object element) throws CoreException {
557557
LocationKind locationKind= null;
558558

559559
file= adaptable.getAdapter(IFile.class);
560-
if (file != null) {
561-
IPath location= file.getFullPath();
562-
locationKind= LocationKind.IFILE;
563-
manager.connect(location, locationKind,getProgressMonitor());
564-
fileBuffer= manager.getTextFileBuffer(location, locationKind);
565-
} else {
566-
ILocationProvider provider= adaptable.getAdapter(ILocationProvider.class);
567-
if (provider instanceof ILocationProviderExtension) {
568-
URI uri= ((ILocationProviderExtension)provider).getURI(element);
569-
if (ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri).length == 0) {
570-
IFileStore fileStore= EFS.getStore(uri);
571-
manager.connectFileStore(fileStore, getProgressMonitor());
572-
fileBuffer= manager.getFileStoreTextFileBuffer(fileStore);
560+
IProgressMonitor progressMonitor= getProgressMonitor();
561+
try {
562+
if (file != null) {
563+
IPath location= file.getFullPath();
564+
locationKind= LocationKind.IFILE;
565+
manager.connect(location, locationKind, progressMonitor);
566+
fileBuffer= manager.getTextFileBuffer(location, locationKind);
567+
} else {
568+
ILocationProvider provider= adaptable.getAdapter(ILocationProvider.class);
569+
if (provider instanceof ILocationProviderExtension) {
570+
URI uri= ((ILocationProviderExtension) provider).getURI(element);
571+
if (ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(uri).length == 0) {
572+
IFileStore fileStore= EFS.getStore(uri);
573+
manager.connectFileStore(fileStore, progressMonitor);
574+
fileBuffer= manager.getFileStoreTextFileBuffer(fileStore);
575+
}
576+
}
577+
if (fileBuffer == null && provider != null) {
578+
IPath location= provider.getPath(element);
579+
if (location == null)
580+
return null;
581+
locationKind= LocationKind.NORMALIZE;
582+
manager.connect(location, locationKind, progressMonitor);
583+
fileBuffer= manager.getTextFileBuffer(location, locationKind);
584+
file= FileBuffers.getWorkspaceFileAtLocation(location);
573585
}
574586
}
575-
if (fileBuffer == null && provider != null) {
576-
IPath location= provider.getPath(element);
577-
if (location == null)
578-
return null;
579-
locationKind= LocationKind.NORMALIZE;
580-
manager.connect(location, locationKind, getProgressMonitor());
581-
fileBuffer= manager.getTextFileBuffer(location, locationKind);
582-
file= FileBuffers.getWorkspaceFileAtLocation(location);
587+
} finally {
588+
if (progressMonitor != null) {
589+
progressMonitor.done();
583590
}
584591
}
585592

@@ -692,14 +699,19 @@ private void removeFileBufferMapping(Object element, FileInfo info) {
692699
*/
693700
protected void disposeFileInfo(Object element, FileInfo info) {
694701
IFileBufferManager manager= FileBuffers.getTextFileBufferManager();
702+
IProgressMonitor progressMonitor= getProgressMonitor();
695703
try {
696704
info.fTextFileBuffer.releaseSynchronizationContext();
697705
if (info.fTextFileBufferLocationKind != null)
698-
manager.disconnect(info.fTextFileBuffer.getLocation(), info.fTextFileBufferLocationKind, getProgressMonitor());
706+
manager.disconnect(info.fTextFileBuffer.getLocation(), info.fTextFileBufferLocationKind, progressMonitor);
699707
else
700-
manager.disconnectFileStore(info.fTextFileBuffer.getFileStore(), getProgressMonitor());
708+
manager.disconnectFileStore(info.fTextFileBuffer.getFileStore(), progressMonitor);
701709
} catch (CoreException x) {
702710
handleCoreException(x, "FileDocumentProvider.disposeElementInfo"); //$NON-NLS-1$
711+
} finally {
712+
if (progressMonitor != null) {
713+
progressMonitor.done();
714+
}
703715
}
704716
}
705717

@@ -747,7 +759,14 @@ public ISchedulingRule getSchedulingRule() {
747759
return null;
748760
}
749761
};
750-
executeOperation(operation, getProgressMonitor());
762+
IProgressMonitor progressMonitor= getProgressMonitor();
763+
try {
764+
executeOperation(operation, progressMonitor);
765+
} finally {
766+
if (progressMonitor != null) {
767+
progressMonitor.done();
768+
}
769+
}
751770
} else {
752771
getParentProvider().resetDocument(element);
753772
}
@@ -1034,7 +1053,14 @@ public ISchedulingRule getSchedulingRule() {
10341053
return null;
10351054
}
10361055
};
1037-
executeOperation(operation, getProgressMonitor());
1056+
IProgressMonitor progressMonitor= getProgressMonitor();
1057+
try {
1058+
executeOperation(operation, progressMonitor);
1059+
} finally {
1060+
if (progressMonitor != null) {
1061+
progressMonitor.done();
1062+
}
1063+
}
10381064
} else
10391065
((IDocumentProviderExtension) getParentProvider()).validateState(element, computationContext);
10401066
}
@@ -1118,7 +1144,14 @@ public ISchedulingRule getSchedulingRule() {
11181144
return null;
11191145
}
11201146
};
1121-
executeOperation(operation, getProgressMonitor());
1147+
IProgressMonitor progressMonitor= getProgressMonitor();
1148+
try {
1149+
executeOperation(operation, progressMonitor);
1150+
} finally {
1151+
if (progressMonitor != null) {
1152+
progressMonitor.done();
1153+
}
1154+
}
11221155
} else {
11231156
((IDocumentProviderExtension) getParentProvider()).synchronize(element);
11241157
}

0 commit comments

Comments
 (0)