On Tue, Nov 07, 2006 at 09:31:35PM -0000, [EMAIL PROTECTED] wrote:
> Author: alstrup
> Date: Tue Nov  7 22:31:33 2006
> New Revision: 15792
> 
> URL: http://www.lyx.org/trac/changeset/15792
> Log:
> - Avoid lyxerr[] like the plague. Use if (lyxerr.debugging( ... )) instead.
> 
> Modified:
>     lyx-devel/trunk/src/BufferView.C
>     lyx-devel/trunk/src/frontends/WorkArea.C
>     lyx-devel/trunk/src/rowpainter.C
>     lyx-devel/trunk/src/text.C
> 
> Modified: lyx-devel/trunk/src/BufferView.C
> URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/BufferView.C?rev=15792
> ==============================================================================
> --- lyx-devel/trunk/src/BufferView.C (original)
> +++ lyx-devel/trunk/src/BufferView.C Tue Nov  7 22:31:33 2006
> @@ -355,7 +355,9 @@
>       if (!buffer_)
>               return false;
>  
> -     lyxerr[Debug::WORKAREA] << "BufferView::update" << std::endl;
> +     if (lyxerr.debugging(Debug::WORKAREA)) {
> +             lyxerr[Debug::WORKAREA] << "BufferView::update" << std::endl;
> +     }

Isn't that equivalent to

 +      if (lyxerr.debugging(Debug::WORKAREA)) {
 +              lyxerr << "BufferView::update" << std::endl;
 +      }

?

Apart from that lyxerr usage is one of the places where I'd prefer real
macros using __FILE__ and __LINE__ that could be used for 'one-click-
navigation'.

#define LYXERR(channel, msg) \
        if (!lyxerr.debugging(channel)) \
                ; \
        else \
                lyxerr << __FILE__ << "(" << __LINE__ << "): " << msg << 
std::endl

and

 LYXERR(Debug::WORKAREA, "BufferView::update");

would do for starters.

Less clutter in the source, faster execution if the message is not shown
and more useful information if it is shown. Pretty much a win-win-win
situation.

Andre'

Reply via email to