This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 47022
Collapse All | Expand All

(-)src/org/openide/text/CloneableEditorSupport.java (-13 / +29 lines)
Lines 425-437 Link Here
425
                        runningInAtomicLock = true;
425
                        runningInAtomicLock = true;
426
                        NbDocument.runAtomic(docToLoad, this);
426
                        NbDocument.runAtomic(docToLoad, this);
427
427
428
                        // Add undoable listener after atomic change has finished
429
                        synchronized (getLock()) {
430
                            if (doc == docToLoad) { // if document still valid
431
                                doc.addUndoableEditListener(getUndoRedo());
432
                            }
433
                        }
434
435
                        return;
428
                        return;
436
                    }
429
                    }
437
430
Lines 462-467 Link Here
462
                            // Confirm that whole loading succeeded
455
                            // Confirm that whole loading succeeded
463
                            targetStatus = DOCUMENT_READY;
456
                            targetStatus = DOCUMENT_READY;
464
457
458
                            // Add undoable listener after atomic change has finished
459
                            if (doc == docToLoad) { // if document still valid
460
                              System.out.println ("Add1:: " + Thread.currentThread());
461
                                doc.addUndoableEditListener(getUndoRedo());
462
                            }
465
                        } catch (RuntimeException t) {
463
                        } catch (RuntimeException t) {
466
                              prepareDocumentRuntimeException = t;
464
                              prepareDocumentRuntimeException = t;
467
                              prepareTask = null;
465
                              prepareTask = null;
Lines 476-482 Link Here
476
474
477
                            synchronized (getLock()) {
475
                            synchronized (getLock()) {
478
                                documentStatus = targetStatus;
476
                                documentStatus = targetStatus;
479
477
                                System.out.println ("Notify1: " + documentStatus);
480
                                getLock().notifyAll();
478
                                getLock().notifyAll();
481
                            }
479
                            }
482
                        }
480
                        }
Lines 485-493 Link Here
485
                }
483
                }
486
            });
484
            });
487
        } catch (RuntimeException ex) {
485
        } catch (RuntimeException ex) {
486
          ex.printStackTrace ();
488
            synchronized (getLock ()) {
487
            synchronized (getLock ()) {
489
                prepareDocumentRuntimeException = ex;
488
                prepareDocumentRuntimeException = ex;
490
                documentStatus = DOCUMENT_NO;
489
                documentStatus = DOCUMENT_NO;
490
                System.out.println ("notify2: " + documentStatus);
491
                getLock ().notifyAll ();
491
                getLock ().notifyAll ();
492
            }
492
            }
493
            throw ex;
493
            throw ex;
Lines 545-550 Link Here
545
     * Must be called under getLock().
545
     * Must be called under getLock().
546
     */
546
     */
547
    private StyledDocument openDocumentImpl() {
547
    private StyledDocument openDocumentImpl() {
548
      System.out.println ("open1: " + Thread.currentThread());
548
        switch (documentStatus) {
549
        switch (documentStatus) {
549
            case DOCUMENT_NO:
550
            case DOCUMENT_NO:
550
                documentStatus = DOCUMENT_LOADING;
551
                documentStatus = DOCUMENT_LOADING;
Lines 556-563 Link Here
556
                return doc;
557
                return doc;
557
                
558
                
558
            default: // loading
559
            default: // loading
559
                try {
560
              try {
560
                    getLock().wait();
561
                System.out.println ("Wait1: " + Thread.currentThread());
562
                getLock().wait();
563
                System.out.println ("After wait: " + Thread.currentThread());
561
                } catch (InterruptedException e) {
564
                } catch (InterruptedException e) {
562
                    ErrorManager.getDefault().notify(
565
                    ErrorManager.getDefault().notify(
563
                         ErrorManager.INFORMATIONAL, e);
566
                         ErrorManager.INFORMATIONAL, e);
Lines 1150-1156 Link Here
1150
                        throw t;
1153
                        throw t;
1151
                    } finally {
1154
                    } finally {
1152
			synchronized (getLock()) {
1155
			synchronized (getLock()) {
1153
                    	    documentStatus = targetStatus;
1156
        documentStatus = targetStatus;
1157
        System.out.println ("notify3: " + documentStatus);
1154
			    getLock().notifyAll();
1158
			    getLock().notifyAll();
1155
                        }
1159
                        }
1156
                    }
1160
                    }
Lines 1183-1189 Link Here
1183
		}
1187
		}
1184
	    });
1188
	    });
1185
	    
1189
	    
1186
	    // Add undoable listener after atomic change has finished
1190
      // Add undoable listener after atomic change has finished
1191
      System.out.println ("Add2: " + Thread.currentThread());
1187
            doc.addUndoableEditListener(getUndoRedo());
1192
            doc.addUndoableEditListener(getUndoRedo());
1188
1193
1189
	    return prepareTask;
1194
	    return prepareTask;
Lines 2217-2222 Link Here
2217
        private CloneableEditorSupport support;
2222
        private CloneableEditorSupport support;
2218
        
2223
        
2219
        public CESUndoRedoManager (CloneableEditorSupport c) {
2224
        public CESUndoRedoManager (CloneableEditorSupport c) {
2225
          Thread.dumpStack();
2220
            this.support = c;
2226
            this.support = c;
2221
        }
2227
        }
2222
2228
Lines 2237-2242 Link Here
2237
            return new RenderUndo (2, myDoc).booleanResult;
2243
            return new RenderUndo (2, myDoc).booleanResult;
2238
        }
2244
        }
2239
2245
2246
        public void undoableEditHappened (UndoableEditEvent ed) {
2247
          System.out.println ("undoable edit: " + ed + " thread: " + Thread.currentThread ());
2248
          super.undoableEditHappened (ed);
2249
          System.out.println ("  end lenght: " + edits.size ());
2250
        }
2251
        
2252
2240
        public boolean canUndo() {
2253
        public boolean canUndo() {
2241
            final StyledDocument myDoc = support.getDocument();
2254
            final StyledDocument myDoc = support.getDocument();
2242
            return new RenderUndo (3, myDoc).booleanResult;
2255
            return new RenderUndo (3, myDoc).booleanResult;
Lines 2284-2290 Link Here
2284
        }
2297
        }
2285
        
2298
        
2286
        private final class RenderUndo implements Runnable {
2299
        private final class RenderUndo implements Runnable {
2287
            private final int type;
2300
          private final int type;
2301
          private final StyledDocument doc;
2288
            public boolean booleanResult;
2302
            public boolean booleanResult;
2289
            public int intResult;
2303
            public int intResult;
2290
            public String stringResult;
2304
            public String stringResult;
Lines 2296-2301 Link Here
2296
            public RenderUndo (int type, StyledDocument doc, int intValue) {
2310
            public RenderUndo (int type, StyledDocument doc, int intValue) {
2297
                this.type = type;
2311
                this.type = type;
2298
                this.intResult = intValue;
2312
                this.intResult = intValue;
2313
                this.doc = doc;
2299
                
2314
                
2300
                if (doc instanceof NbDocument.WriteLockable) {
2315
                if (doc instanceof NbDocument.WriteLockable) {
2301
                    ((NbDocument.WriteLockable)doc).runAtomic (this);
2316
                    ((NbDocument.WriteLockable)doc).runAtomic (this);
Lines 2311-2316 Link Here
2311
            }
2326
            }
2312
            
2327
            
2313
            public void run () {
2328
            public void run () {
2329
              System.out.println ("render: " + type + " from thread: " + Thread.currentThread() + " doc: " + doc);
2314
                switch (type) {
2330
                switch (type) {
2315
                    case 0: CESUndoRedoManager.super.redo (); break;
2331
                    case 0: CESUndoRedoManager.super.redo (); break;
2316
                    case 1: CESUndoRedoManager.super.undo (); break;
2332
                    case 1: CESUndoRedoManager.super.undo (); break;

Return to bug 47022