Index: openide/src/org/openide/text/PositionRef.java =================================================================== RCS file: /cvs/openide/src/org/openide/text/PositionRef.java,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- openide/src/org/openide/text/PositionRef.java 9 Mar 2004 12:57:06 -0000 1.53 +++ openide/src/org/openide/text/PositionRef.java 11 Mar 2004 09:43:54 -0000 1.54 @@ -363,9 +363,10 @@ pos.kind.toMemory(pos.insertAfter)); } */ - - kind = (Kind)new DocumentRenderer(DocumentRenderer.ADD_POSITION, pos).renderToObject(); - + // [pnejedly] needed to prevent doc variable modification while adding position, #40766 + synchronized(support.docStateLock) { + kind = (Kind)new DocumentRenderer(DocumentRenderer.ADD_POSITION, pos).renderToObject(); + } checkQueue(); return kind; Index: openide/src/org/openide/text/CloneableEditorSupport.java =================================================================== RCS file: /cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v retrieving revision 1.117 retrieving revision 1.118 diff -u -r1.117 -r1.118 --- openide/src/org/openide/text/CloneableEditorSupport.java 1 Mar 2004 17:18:29 -0000 1.117 +++ openide/src/org/openide/text/CloneableEditorSupport.java 11 Mar 2004 09:43:54 -0000 1.118 @@ -137,6 +137,12 @@ /** position manager */ private PositionRef.Manager positionManager; + /* [pnejedly] This lock is shared by PositionRef.Manager and this class + * to prevent PR.M modifications while the document is just loaded + * or freed. See #40766. + */ + Object docStateLock = new Object(); + /** The string which will be appended to the name of top component * when top component becomes modified */ // protected String modifiedAppendix = " *"; // NOI18N @@ -403,8 +409,9 @@ // where another threads may operate already if (!runningInAtomicLock) { runningInAtomicLock = true; - NbDocument.runAtomic(docToLoad, this); - + synchronized (docStateLock) { // [pnejedly] See #40766 + NbDocument.runAtomic(docToLoad, this); + } // Add undoable listener after atomic change has finished synchronized (getLock()) { if (doc == docToLoad) { // if document still valid @@ -1457,6 +1464,7 @@ /** Clears all data from memory. */ private void closeDocument () { + synchronized(docStateLock) { // [pnejedly] See #40766 synchronized (getLock()) { while (true) { switch (documentStatus) { @@ -1475,6 +1483,7 @@ } } } + } } /** Is called under getLock () to close the document.