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.
Created attachment 94301 [details] Unit test to demonstrate the problem I am working on fix for bug 180614. However I have troubles to update state of Undo and Redo actions from inside undoableEditHappened listener event. The BaseDocument's locking mechanism gets confused somehow. But I need to do it. I need to call UndoRedo.Manager (which acquires render lock on document) to find out whether canUndo and canRedo shall be enabled or not. I am attaching simple test to demonstrate similar problem. The whole issue can be analyzed by applying patch provided for bug 180614.
I don't think this is related to Printing & Painting...
Yardo, if you would use doc.render(run); inside undoableEditHappened() it would work as expected. The doc.runAtomic(run) does not work but it gives me a little meaning to use it inside undoableEditHappened() since you should not mutate the document there anyway. Is there any good reason why runAtomic() is necessary?
I can easily change the unit test, but the problem is that CloneableEditorSupport.getUndoRedo().canUndo() is using runAtomic. Who wants to change that? Imho, the runAtomic is there to prevent deadlocks.
Yes, I know, I've already had a patch for CESUndoRedoManager's canUndo() and canRedo() with doc.render() and it seems to work fine so we could consider it.
Created attachment 94961 [details] Patch for CESUndoRedoManager
BTW the partial code change in the patch for BaseDocument can stay it only clears the instance vars before firing the change. However it does not suffice for making your original test pass.
The openide.text unit tests pass so I've committed the change. http://hg.netbeans.org/jet-main/rev/41e2579c1947
Integrated into 'main-golden', will be available in build *201003180200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/41e2579c1947 User: Miloslav Metelka <mmetelka@netbeans.org> Log: #180920 - Cannot "render" from inside undoableEditHappened - UndoRedo.canUndo()/canRedo() now use Document.render()
I am still getting NPE (with the bug 180614 patch) when typing a character in java editor: java.lang.NullPointerException at org.netbeans.editor.BaseDocument.notifyModify(BaseDocument.java:1838) at org.netbeans.editor.BaseDocument.atomicUnlockImpl(BaseDocument.java:1801) at org.netbeans.editor.GuardedDocument.runAtomicAsUser(GuardedDocument.java:350) at org.netbeans.editor.BaseKit$DefaultKeyTypedAction.actionPerformed(BaseKit.java:1065) at org.netbeans.editor.ext.ExtKit$ExtDefaultKeyTypedAction.actionPerformed(ExtKit.java:1046) at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:336) at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636) at javax.swing.JComponent.processKeyBinding(JComponent.java:2851) at javax.swing.JComponent.processKeyBindings(JComponent.java:2886) at javax.swing.JComponent.processKeyEvent(JComponent.java:2814) at java.awt.Component.processEvent(Component.java:6040)
I think this should solve the NPE. http://hg.netbeans.org/jet-main/rev/9f5cece14acf
Integrated into 'main-golden', will be available in build *201003240200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/9f5cece14acf User: Vita Stejskal <vstejskal@netbeans.org> Log: #180920: following up on 41e2579c1947, there are more readonly operations
*** Bug 184163 has been marked as a duplicate of this bug. ***