[QGIS-Developer] C++ debugging policy/strategy

Sandro Santilli strk at kbt.io
Thu Sep 29 09:42:05 PDT 2022


On Mon, Sep 26, 2022 at 09:05:14AM +1000, Nyall Dawson wrote:

> Don't push code to QGIS master which uses QgsDebugMsg() for anything
> BUT reporting unanticipated errors.

Shouldn't those report an error rather than a Debug ?

> For all other cases you must use
> QgsDebugMsgLevel( "message", level ), where
> -   level = 2: for occasionally hit code paths and highly useful
> priority debug messages
> -   level = 3: more often hit code paths, more esoteric debug messages
> -   level = 4: for super-noisy debugging messages in frequently called code

Thanks for the sum-up

> >   CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsRectangle &rectangle );
> >
> >   inline std::ostream &operator << ( std::ostream &os, const QgsRectangle &r) {...}
> 
> This is an outlier -- it's ancient unused code from > 15 years ago

Which one is the one that would be used by "".arg() ?

> Also relevant are the various "char *toString( const QgsXXXXX& val )"
> methods defined in qgstest.h -- these ARE relevant, and are used when
> reporting test failures by the QCOMPARE macro.

Does this mean it takes qgtest.h inclusion to debug ?

Is there a development guide to recommend one approach over the other ?
I could not find a specific chapter on this here:

https://docs.qgis.org/3.22/en/docs/developers_guide/codingstandards.html

--strk;


More information about the QGIS-Developer mailing list