From 44b212878b7faa7b6f3e887c1f41282c774cac49 Mon Sep 17 00:00:00 2001 From: Asger Ottar Alstrup Date: Tue, 7 Nov 2006 21:31:33 +0000 Subject: [PATCH] - Avoid lyxerr[] like the plague. Use if (lyxerr.debugging( ... )) instead. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15792 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 16 ++++++++++------ src/frontends/WorkArea.C | 4 +++- src/rowpainter.C | 22 ++++++++++++++-------- src/text.C | 18 +++++++++++------- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index f092691129..39c8da3162 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -355,7 +355,9 @@ bool BufferView::update(Update::flags flags) if (!buffer_) return false; - lyxerr[Debug::WORKAREA] << "BufferView::update" << std::endl; + if (lyxerr.debugging(Debug::WORKAREA)) { + lyxerr[Debug::WORKAREA] << "BufferView::update" << std::endl; + } // Update macro store buffer_->buildMacros(); @@ -388,11 +390,13 @@ void BufferView::updateScrollbar() offset_ref_ = 0; } - lyxerr[Debug::GUI] - << BOOST_CURRENT_FUNCTION - << " Updating scrollbar: height: " << t.paragraphs().size() - << " curr par: " << cursor_.bottom().pit() - << " default height " << defaultRowHeight() << endl; + if (lyxerr.debugging(Debug::GUI)) { + lyxerr[Debug::GUI] + << BOOST_CURRENT_FUNCTION + << " Updating scrollbar: height: " << t.paragraphs().size() + << " curr par: " << cursor_.bottom().pit() + << " default height " << defaultRowHeight() << endl; + } // It would be better to fix the scrollbar to understand // values in [0..1] and divide everything by wh diff --git a/src/frontends/WorkArea.C b/src/frontends/WorkArea.C index ec44b875a4..2d6663cf4d 100644 --- a/src/frontends/WorkArea.C +++ b/src/frontends/WorkArea.C @@ -153,7 +153,9 @@ void WorkArea::redraw(bool singlePar) ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo(); greyed_out_ = false; - lyxerr[Debug::WORKAREA] << "WorkArea::redraw screen" << endl; + if (lyxerr.debugging(Debug::WORKAREA)) { + lyxerr[Debug::WORKAREA] << "WorkArea::redraw screen" << endl; + } int const ymin = std::max(vi.y1, 0); int const ymax = vi.p2 < vi.size - 1 ? vi.y2 : height(); diff --git a/src/rowpainter.C b/src/rowpainter.C index e357550411..fdb3450e64 100644 --- a/src/rowpainter.C +++ b/src/rowpainter.C @@ -182,7 +182,9 @@ void RowPainter::paintInset(pos_type const pos, LyXFont const & font) bool tmp = refreshInside; if (!in || !in->wide()) { refreshInside = true; - lyxerr[Debug::PAINTING] << endl << "Paint inset fully" << endl; + if (lyxerr.debugging(Debug::PAINTING)) { + lyxerr << endl << "Paint inset fully" << endl; + } } if (refreshInside) inset->drawSelection(pi, int(x_), yo_); @@ -921,12 +923,14 @@ void paintPar // Instrumentation for testing row cache (see also // 12 lines lower): - if (text.isMainText(*pi.base.bv->buffer())) - lyxerr[Debug::PAINTING] << "#"; - else - lyxerr[Debug::PAINTING] << "[" << - repaintAll << row_has_changed << - cursor_on_row << "]"; + if (lyxerr.debugging(Debug::PAINTING)) { + if (text.isMainText(*pi.base.bv->buffer())) + lyxerr[Debug::PAINTING] << "#"; + else + lyxerr[Debug::PAINTING] << "[" << + repaintAll << row_has_changed << + cursor_on_row << "]"; + } rp.paintAppendix(); rp.paintDepthBar(); rp.paintChangeBar(); @@ -943,7 +947,9 @@ void paintPar // Re-enable screen drawing for future use of the painter. pi.pain.setDrawingEnabled(true); - lyxerr[Debug::PAINTING] << "." << endl; + if (lyxerr.debugging(Debug::PAINTING)) { + lyxerr[Debug::PAINTING] << "." << endl; + } } } // namespace anon diff --git a/src/text.C b/src/text.C index a933287f91..872ef17c1b 100644 --- a/src/text.C +++ b/src/text.C @@ -1962,10 +1962,12 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const if (!ptr_cmp(cur.text(), this)) return; - lyxerr[Debug::DEBUG] - << BOOST_CURRENT_FUNCTION - << "draw selection at " << x - << endl; + if (lyxerr.debugging(Debug::DEBUG)) { + lyxerr[Debug::DEBUG] + << BOOST_CURRENT_FUNCTION + << "draw selection at " << x + << endl; + } DocIterator beg = cur.selectionBegin(); DocIterator end = cur.selectionEnd(); @@ -2037,9 +2039,11 @@ void LyXText::drawSelection(PainterInfo & pi, int x, int) const return; } - lyxerr[Debug::DEBUG] << " y1: " << y1 << " y2: " << y2 - << "X1:" << X1 << " x2: " << X2 << " wid: " << dim_.wid - << endl; + if (lyxerr.debugging(Debug::DEBUG)) { + lyxerr[Debug::DEBUG] << " y1: " << y1 << " y2: " << y2 + << "X1:" << X1 << " x2: " << X2 << " wid: " << dim_.wid + << endl; + } // paint upper rectangle pi.pain.fillRectangle(x + x1, y1, x2 - x1, y2 - y1, -- 2.39.2