From 0b4a680dbb18bc43a489991197f5c25bcab07267 Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Tue, 1 Jun 2021 23:14:14 -0400 Subject: [PATCH] Hotglue wxLogDebug into math/util.h without the global include --- libs/kimath/include/math/util.h | 7 +++++++ libs/kimath/src/math/util.cpp | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libs/kimath/include/math/util.h b/libs/kimath/include/math/util.h index c7329a1faf..32cda82a14 100644 --- a/libs/kimath/include/math/util.h +++ b/libs/kimath/include/math/util.h @@ -31,6 +31,11 @@ #include #include +/** + * Helper to avoid directly including wx/log.h for the templated functions in kimath + */ +void kimathLogDebug( const char* aFormatString, ... ); + /** * Function Clamp * limits @a value within the range @a lower <= @a value <= @a upper. It will work @@ -70,6 +75,8 @@ constexpr ret_type KiROUND( fp_type v ) if( std::numeric_limits::max() < ret || std::numeric_limits::lowest() > ret ) { + kimathLogDebug( "Overflow KiROUND converting value %f to %s", double( v ), + typeid( ret_type ).name() ); return 0; } diff --git a/libs/kimath/src/math/util.cpp b/libs/kimath/src/math/util.cpp index dd74dc4d43..4998bc0fea 100644 --- a/libs/kimath/src/math/util.cpp +++ b/libs/kimath/src/math/util.cpp @@ -27,6 +27,21 @@ #include #include #include +#include + +void kimathLogDebug( const char* aFormatString, ... ) +{ + if( wxLog::IsLevelEnabled( wxLOG_Debug, wxASCII_STR( wxLOG_COMPONENT ) ) ) + { + va_list argList; + va_start( argList, aFormatString ); + + wxVLogWarning( aFormatString, argList ); + + va_end( argList ); + } +} + template<> int rescale( int aNumerator, int aValue, int aDenominator )