? X.diff Index: src/org/openide/text/CloneableEditorSupport.java =================================================================== RCS file: /cvs/openide/src/org/openide/text/CloneableEditorSupport.java,v retrieving revision 1.129 diff -u -r1.129 CloneableEditorSupport.java --- src/org/openide/text/CloneableEditorSupport.java 12 Aug 2004 13:29:10 -0000 1.129 +++ src/org/openide/text/CloneableEditorSupport.java 24 Aug 2004 08:09:24 -0000 @@ -425,13 +425,6 @@ runningInAtomicLock = true; NbDocument.runAtomic(docToLoad, this); - // Add undoable listener after atomic change has finished - synchronized (getLock()) { - if (doc == docToLoad) { // if document still valid - doc.addUndoableEditListener(getUndoRedo()); - } - } - return; } @@ -462,6 +455,11 @@ // Confirm that whole loading succeeded targetStatus = DOCUMENT_READY; + // Add undoable listener after atomic change has finished + if (doc == docToLoad) { // if document still valid + System.out.println ("Add1:: " + Thread.currentThread()); + doc.addUndoableEditListener(getUndoRedo()); + } } catch (RuntimeException t) { prepareDocumentRuntimeException = t; prepareTask = null; @@ -476,7 +474,7 @@ synchronized (getLock()) { documentStatus = targetStatus; - + System.out.println ("Notify1: " + documentStatus); getLock().notifyAll(); } } @@ -485,9 +483,11 @@ } }); } catch (RuntimeException ex) { + ex.printStackTrace (); synchronized (getLock ()) { prepareDocumentRuntimeException = ex; documentStatus = DOCUMENT_NO; + System.out.println ("notify2: " + documentStatus); getLock ().notifyAll (); } throw ex; @@ -545,6 +545,7 @@ * Must be called under getLock(). */ private StyledDocument openDocumentImpl() { + System.out.println ("open1: " + Thread.currentThread()); switch (documentStatus) { case DOCUMENT_NO: documentStatus = DOCUMENT_LOADING; @@ -556,8 +557,10 @@ return doc; default: // loading - try { - getLock().wait(); + try { + System.out.println ("Wait1: " + Thread.currentThread()); + getLock().wait(); + System.out.println ("After wait: " + Thread.currentThread()); } catch (InterruptedException e) { ErrorManager.getDefault().notify( ErrorManager.INFORMATIONAL, e); @@ -1150,7 +1153,8 @@ throw t; } finally { synchronized (getLock()) { - documentStatus = targetStatus; + documentStatus = targetStatus; + System.out.println ("notify3: " + documentStatus); getLock().notifyAll(); } } @@ -1183,7 +1187,8 @@ } }); - // Add undoable listener after atomic change has finished + // Add undoable listener after atomic change has finished + System.out.println ("Add2: " + Thread.currentThread()); doc.addUndoableEditListener(getUndoRedo()); return prepareTask; @@ -2217,6 +2222,7 @@ private CloneableEditorSupport support; public CESUndoRedoManager (CloneableEditorSupport c) { + Thread.dumpStack(); this.support = c; } @@ -2237,6 +2243,13 @@ return new RenderUndo (2, myDoc).booleanResult; } + public void undoableEditHappened (UndoableEditEvent ed) { + System.out.println ("undoable edit: " + ed + " thread: " + Thread.currentThread ()); + super.undoableEditHappened (ed); + System.out.println (" end lenght: " + edits.size ()); + } + + public boolean canUndo() { final StyledDocument myDoc = support.getDocument(); return new RenderUndo (3, myDoc).booleanResult; @@ -2284,7 +2297,8 @@ } private final class RenderUndo implements Runnable { - private final int type; + private final int type; + private final StyledDocument doc; public boolean booleanResult; public int intResult; public String stringResult; @@ -2296,6 +2310,7 @@ public RenderUndo (int type, StyledDocument doc, int intValue) { this.type = type; this.intResult = intValue; + this.doc = doc; if (doc instanceof NbDocument.WriteLockable) { ((NbDocument.WriteLockable)doc).runAtomic (this); @@ -2311,6 +2326,7 @@ } public void run () { + System.out.println ("render: " + type + " from thread: " + Thread.currentThread() + " doc: " + doc); switch (type) { case 0: CESUndoRedoManager.super.redo (); break; case 1: CESUndoRedoManager.super.undo (); break;