diff --git a/include/internal/catch_console_colour_impl.hpp b/include/internal/catch_console_colour_impl.hpp index b1db918c..0d184131 100644 --- a/include/internal/catch_console_colour_impl.hpp +++ b/include/internal/catch_console_colour_impl.hpp @@ -126,19 +126,22 @@ namespace Catch { void use( Colour::Code ) {} }; NoColourImpl noColourImpl; - static const bool shouldUseColour = shouldUseColourForPlatform() && - !isDebuggerActive(); } Colour::Colour( Code _colourCode ){ use( _colourCode ); } Colour::~Colour(){ use( None ); } void Colour::use( Code _colourCode ) { + + if (impl == NULL) { + impl = (shouldUseColourForPlatform() && !isDebuggerActive()) + ? static_cast( &platformColourImpl ) + : static_cast( &noColourImpl ); + } + impl->use( _colourCode ); } - Detail::IColourImpl* Colour::impl = shouldUseColour - ? static_cast( &platformColourImpl ) - : static_cast( &noColourImpl ); + Detail::IColourImpl* Colour::impl = NULL; } // end namespace Catch