← Back to team overview

kicad-developers team mailing list archive

Re: [Bug 1250876] Re: DisplayError / tool_manager.cpp compile failure

 

On 11/13/2013 09:28 AM, Wayne Stambaugh wrote:
> Fix committed in r4463.
> 
> ** Changed in: kicad
>        Status: New => Fix Committed
> 

tool_manager.cpp:

line 142 is using concatonation against a format string, this is a bug.

If you want formatting, we need wxString::Format() or the new std::string StrPrintf() or
similar.

If the format string is not going to be translated, then there are savings by going down
to an 8 bit string.  On linux, wxT() creates a 32 bit string, which takes up 4 times the
memory of an 8 bit string.


Further consideration has us anticipating a transition to wx 3.x on all platforms, at
which point we can remove all wxT() instances, supposedly.  That also will be a transition
to 8 bit constant strings, one we have to wait for.

So there are two paths forward, both sensible, one you have to wait for.

The deciding factor for me is that aTool->GetName() returns

   const std::string&

so we start with an 8 bit string.

So I offer the attached patch.







=== modified file 'common/tool/tool_manager.cpp'
--- common/tool/tool_manager.cpp	2013-11-13 14:52:06 +0000
+++ common/tool/tool_manager.cpp	2013-11-13 16:42:35 +0000
@@ -139,8 +139,9 @@
     {
         if( !static_cast<TOOL_INTERACTIVE*>( aTool )->Init() )
         {
-            DisplayError( NULL, wxT( "Initialization of the %s tool failed" ) +
-                                     wxString( aTool->GetName().c_str(), wxConvUTF8 ) );
+            std::string msg = StrPrintf( "Initialization of the %s tool failed", aTool->GetName().c_str() );
+
+            DisplayError( NULL, wxString::FromUTF8( msg.c_str() ) );
 
             // Unregister the tool
             m_toolState.erase( aTool );


Follow ups