1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-20 07:25:23 +02:00

Fixed an NPE (bug 248359, comment #22)

This commit is contained in:
Sergey Prigogin 2009-04-23 07:19:29 +00:00
parent 6d64bcb42a
commit 3bd59df377

View file

@ -82,7 +82,6 @@ import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.ICPartitions;
import org.eclipse.cdt.internal.core.model.CommitWorkingCopyOperation;
import org.eclipse.cdt.internal.core.model.IBufferFactory; import org.eclipse.cdt.internal.core.model.IBufferFactory;
import org.eclipse.cdt.internal.core.model.TranslationUnit; import org.eclipse.cdt.internal.core.model.TranslationUnit;
@ -963,14 +962,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
IDocument document= info.fTextFileBuffer.getDocument(); IDocument document= info.fTextFileBuffer.getDocument();
IResource resource= info.fCopy.getResource(); IResource resource= info.fCopy.getResource();
boolean isSynchronized= resource.isSynchronized(IResource.DEPTH_ZERO);
// Make sure file gets save in commit() if the underlying file has been deleted
if (!isSynchronized && isDeleted(element))
info.fTextFileBuffer.setDirty(true);
if (resource instanceof IFile && !resource.exists()) { if (resource instanceof IFile && !resource.exists()) {
// Underlying resource has been deleted, just recreate file, ignore the rest // The underlying resource has been deleted, just recreate the file, ignore the rest
createFileFromDocument(monitor, (IFile) resource, document); createFileFromDocument(monitor, (IFile) resource, document);
return; return;
} }
@ -983,18 +976,17 @@ public class CDocumentProvider extends TextFileDocumentProvider {
saveActionException = e; saveActionException = e;
} }
CommitWorkingCopyOperation op= new CommitWorkingCopyOperation(info.fCopy, isSynchronized || overwrite); commitFileBuffer(monitor, info, overwrite);
op.runOperation(getSubProgressMonitor(monitor, 80));
if (saveActionException != null) { if (saveActionException != null) {
throw saveActionException; throw saveActionException;
} }
} catch (CoreException x) { } catch (CoreException x) {
// inform about the failure // Inform about the failure
fireElementStateChangeFailed(element); fireElementStateChangeFailed(element);
throw x; throw x;
} catch (RuntimeException x) { } catch (RuntimeException x) {
// inform about the failure // Inform about the failure
fireElementStateChangeFailed(element); fireElementStateChangeFailed(element);
throw x; throw x;
} }