diff --git a/common/gal/opengl/opengl_gal.cpp b/common/gal/opengl/opengl_gal.cpp index 3bb06802e3..1764281d42 100644 --- a/common/gal/opengl/opengl_gal.cpp +++ b/common/gal/opengl/opengl_gal.cpp @@ -1617,51 +1617,51 @@ void OPENGL_GAL::BitmapText( const wxString& aText, const VECTOR2I& aPosition, int braceNesting = 0; auto iterateString = - [&]( std::function<void( int aOverbarLength, int aOverbarHeight )> overbarFn, - std::function<int( unsigned long aChar )> bitmapCharFn ) - { - for( UTF8::uni_iter chIt = text.ubegin(), end = text.uend(); chIt < end; ++chIt ) - { - wxASSERT_MSG( *chIt != '\n' && *chIt != '\r', - "No support for multiline bitmap text yet" ); - - if( *chIt == '~' && overbarDepth == -1 ) + [&]( const std::function<void( int aOverbarLength, int aOverbarHeight )>& overbarFn, + const std::function<int( unsigned long aChar )>& bitmapCharFn ) { - UTF8::uni_iter lookahead = chIt; - - if( ++lookahead != end && *lookahead == '{' ) + for( UTF8::uni_iter chIt = text.ubegin(), end = text.uend(); chIt < end; ++chIt ) { - chIt = lookahead; - overbarDepth = braceNesting; - braceNesting++; - continue; + wxASSERT_MSG( *chIt != '\n' && *chIt != '\r', + "No support for multiline bitmap text yet" ); + + if( *chIt == '~' && overbarDepth == -1 ) + { + UTF8::uni_iter lookahead = chIt; + + if( ++lookahead != end && *lookahead == '{' ) + { + chIt = lookahead; + overbarDepth = braceNesting; + braceNesting++; + continue; + } + } + else if( *chIt == '{' ) + { + braceNesting++; + } + else if( *chIt == '}' ) + { + if( braceNesting > 0 ) + braceNesting--; + + if( braceNesting == overbarDepth ) + { + overbarFn( overbarLength, overbarHeight ); + overbarLength = 0; + + overbarDepth = -1; + continue; + } + } + + if( overbarDepth != -1 ) + overbarLength += bitmapCharFn( *chIt ); + else + bitmapCharFn( *chIt ); } - } - else if( *chIt == '{' ) - { - braceNesting++; - } - else if( *chIt == '}' ) - { - if( braceNesting > 0 ) - braceNesting--; - - if( braceNesting == overbarDepth ) - { - overbarFn( overbarLength, overbarHeight ); - overbarLength = 0; - - overbarDepth = -1; - continue; - } - } - - if( overbarDepth != -1 ) - overbarLength += bitmapCharFn( *chIt ); - else - bitmapCharFn( *chIt ); - } - }; + }; // First, calculate the amount of characters and overbars to reserve diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index ddad11cfd0..90be73f84d 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -69,7 +69,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const TOOL_EVENT& aTool, aPlacer->m_modifiers = 0; auto makeNewItem = - [&]( VECTOR2I aPosition ) + [&]( const VECTOR2I& aPosition ) { if( frame()->GetModel() ) newItem = aPlacer->CreateItem();