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 37767
Collapse All | Expand All

(-)src/org/openide/text/DocumentLine.java (-2 / +22 lines)
Lines 892-898 Link Here
892
            int newLine = listener.getLine (line);
892
            int newLine = listener.getLine (line);
893
            int offset = NbDocument.findLineOffset (listener.doc, newLine);
893
            int offset = NbDocument.findLineOffset (listener.doc, newLine);
894
894
895
            return this.registerLine(createLine(offset));
895
            return safelyRegisterLine(createLine(offset));
896
        }
896
        }
897
897
898
        /* Creates current line.
898
        /* Creates current line.
Lines 903-909 Link Here
903
        public Line getCurrent (int line) throws IndexOutOfBoundsException {
903
        public Line getCurrent (int line) throws IndexOutOfBoundsException {
904
            int offset = NbDocument.findLineOffset (listener.doc, line);
904
            int offset = NbDocument.findLineOffset (listener.doc, line);
905
905
906
            return this.registerLine(createLine(offset));
906
            return safelyRegisterLine(createLine(offset));
907
        }
907
        }
908
908
909
        /** Creates a {@link Line} for a given offset.
909
        /** Creates a {@link Line} for a given offset.
Lines 912-917 Link Here
912
        */
912
        */
913
        protected abstract Line createLine (int offset);
913
        protected abstract Line createLine (int offset);
914
914
915
        /** Registers line, but only after obtaining the lock of the document.
916
         * This is a fix to issue 37767 as this creates ordering of locks (first 
917
         * of all obtain documentrenderer, then ask for any other locks like
918
         * Line.Set.lines.
919
         *
920
         * @param line line we want to register
921
         * @return the line or some line that already was registered
922
         */
923
        private Line safelyRegisterLine (final Line line) {
924
            class DocumentRenderer implements Runnable {
925
                public Line result;
926
                
927
                public void run () {
928
                    result = DocumentLine.Set.super.registerLine (line);
929
                }
930
            }
931
            DocumentRenderer renderer = new DocumentRenderer ();
932
            listener.doc.render (renderer);
933
            return renderer.result;
934
        }
915
    }
935
    }
916
936
917
937

Return to bug 37767