From f584b30c73b90751c7b50ccda6730e04bcd89c4c Mon Sep 17 00:00:00 2001
From: Wayne Stambaugh <stambaughw@gmail.com>
Date: Wed, 17 Oct 2018 15:03:33 -0400
Subject: [PATCH] Replace log debugging output with tracing.

Replace all instances of wxLogDebug with wxLogTrace in the common and
kicad folders to prevent unwanted debugging output.

Add new trace flags for locale and screen object tracing.

The usual smattering of code policy fixes.
---
 common/base_screen.cpp            | 26 +++++----
 common/pgm_base.cpp               | 56 ++++++++++---------
 common/search_stack.cpp           |  8 +--
 common/searchhelpfilefullpath.cpp | 31 ++++++-----
 common/trace_helpers.cpp          |  2 +
 include/trace_helpers.h           | 10 ++++
 kicad/tree_project_frame.cpp      | 91 ++++++++++++++++---------------
 7 files changed, 124 insertions(+), 100 deletions(-)

diff --git a/common/base_screen.cpp b/common/base_screen.cpp
index ab98fb86e7..84c253e99a 100644
--- a/common/base_screen.cpp
+++ b/common/base_screen.cpp
@@ -3,8 +3,8 @@
  *
  * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
- * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
- * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
+ * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -36,9 +36,12 @@
 #include <base_screen.h>
 #include <id.h>
 #include <base_units.h>
+#include <trace_helpers.h>
+
 
 wxString BASE_SCREEN::m_PageLayoutDescrFileName;   // the name of the page layout descr file.
 
+
 BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) :
     EDA_ITEM( aType )
 {
@@ -122,7 +125,7 @@ bool BASE_SCREEN::SetZoom( double iu_per_du )
     if( iu_per_du == m_Zoom )
         return false;
 
-    //wxLogDebug( "Zoom:%.16g  1/Zoom:%.16g", iu_per_du, 1/iu_per_du );
+    wxLogTrace( traceScreen, "Zoom:%.16g  1/Zoom:%.16g", iu_per_du, 1/iu_per_du );
 
     if( iu_per_du < GetMinAllowedZoom() )
         return false;
@@ -282,21 +285,20 @@ int BASE_SCREEN::SetGrid( int aCommandId  )
 }
 
 
-
 void BASE_SCREEN::AddGrid( const GRID_TYPE& grid )
 {
     for( unsigned i = 0; i < m_grids.size(); i++ )
     {
         if( m_grids[i].m_Size == grid.m_Size && grid.m_CmdId != ID_POPUP_GRID_USER )
         {
-            wxLogDebug( wxT( "Discarding duplicate grid size( %g, %g )." ),
+            wxLogTrace( traceScreen,  "Discarding duplicate grid size( %g, %g ).",
                         grid.m_Size.x, grid.m_Size.y );
             return;
         }
 
         if( m_grids[i].m_CmdId == grid.m_CmdId )
         {
-            wxLogDebug( wxT( "Changing grid ID %d from size( %g, %g ) to " ) \
+            wxLogTrace( traceScreen, wxT( "Changing grid ID %d from size( %g, %g ) to " ) \
                         wxT( "size( %g, %g )." ),
                         grid.m_CmdId, m_grids[i].m_Size.x,
                         m_grids[i].m_Size.y, grid.m_Size.x, grid.m_Size.y );
@@ -380,7 +382,8 @@ wxPoint BASE_SCREEN::getNearestGridPosition( const wxPoint& aPosition,
 }
 
 
-wxPoint BASE_SCREEN::getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin, wxRealPoint* aGridSize ) const
+wxPoint BASE_SCREEN::getCursorPosition( bool aOnGrid, const wxPoint& aGridOrigin,
+                                        wxRealPoint* aGridSize ) const
 {
     if( aOnGrid )
         return getNearestGridPosition( m_crossHairPosition, aGridOrigin, aGridSize );
@@ -401,7 +404,8 @@ wxPoint BASE_SCREEN::getCrossHairScreenPosition() const
 }
 
 
-void BASE_SCREEN::setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin, bool aSnapToGrid )
+void BASE_SCREEN::setCrossHairPosition( const wxPoint& aPosition, const wxPoint& aGridOrigin,
+                                        bool aSnapToGrid )
 {
     if( aSnapToGrid )
         m_crossHairPosition = getNearestGridPosition( aPosition, aGridOrigin, NULL );
@@ -425,6 +429,7 @@ void BASE_SCREEN::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
     if( m_UndoRedoCountMax > 0 )
     {
         int extraitems = GetUndoCommandCount() - m_UndoRedoCountMax;
+
         if( extraitems > 0 )
             ClearUndoORRedoList( m_UndoList, extraitems );
     }
@@ -439,6 +444,7 @@ void BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
     if( m_UndoRedoCountMax > 0 )
     {
         int extraitems = GetRedoCommandCount() - m_UndoRedoCountMax;
+
         if( extraitems > 0 )
             ClearUndoORRedoList( m_RedoList, extraitems );
     }
@@ -447,13 +453,13 @@ void BASE_SCREEN::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
 
 PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromUndoList( )
 {
-    return m_UndoList.PopCommand( );
+    return m_UndoList.PopCommand();
 }
 
 
 PICKED_ITEMS_LIST* BASE_SCREEN::PopCommandFromRedoList( )
 {
-    return m_RedoList.PopCommand( );
+    return m_RedoList.PopCommand();
 }
 
 
diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp
index c7997e0f41..fd95e5dda8 100644
--- a/common/pgm_base.cpp
+++ b/common/pgm_base.cpp
@@ -54,6 +54,7 @@
 #include <dialog_configure_paths.h>
 #include <lockfile.h>
 #include <systemdirsappend.h>
+#include <trace_helpers.h>
 #include <gal/gal_display_options.h>
 
 #define KICAD_COMMON                     wxT( "kicad_common" )
@@ -195,7 +196,7 @@ void PGM_BASE::SetEditorName( const wxString& aFileName )
 {
     m_editor_name = aFileName;
     wxASSERT( m_common_settings );
-    m_common_settings->Write( wxT( "Editor" ), aFileName );
+    m_common_settings->Write( "Editor", aFileName );
 }
 
 
@@ -205,7 +206,7 @@ const wxString& PGM_BASE::GetEditorName( bool aCanShowFileChooser )
 
     if( !editorname )
     {
-        if( !wxGetEnv( wxT( "EDITOR" ), &editorname ) )
+        if( !wxGetEnv( "EDITOR", &editorname ) )
         {
             // If there is no EDITOR variable set, try the desktop default
 #ifdef __WXMAC__
@@ -284,7 +285,7 @@ bool PGM_BASE::InitPgm()
     // Init KiCad environment
     // the environment variable KICAD (if exists) gives the kicad path:
     // something like set KICAD=d:\kicad
-    bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_kicad_env );
+    bool isDefined = wxGetEnv( "KICAD", &m_kicad_env );
 
     if( isDefined )    // ensure m_kicad_env ends by "/"
     {
@@ -295,7 +296,7 @@ bool PGM_BASE::InitPgm()
     }
 
     // Init parameters for configuration
-    App().SetVendorName( wxT( "KiCad" ) );
+    App().SetVendorName( "KiCad" );
     App().SetAppName( pgm_name.GetName().Lower() );
 
     // Install some image handlers, mainly for help
@@ -348,8 +349,8 @@ bool PGM_BASE::InitPgm()
 #endif
 
 #if !defined( __WXMAC__ )
-    baseSharePath.AppendDir( wxT( "share" ) );
-    baseSharePath.AppendDir( wxT( "kicad" ) );
+    baseSharePath.AppendDir( "share" );
+    baseSharePath.AppendDir( "kicad" );
 #endif
 
     // KISYSMOD
@@ -363,7 +364,7 @@ bool PGM_BASE::InitPgm()
     else
     {
         tmpFileName = baseSharePath;
-        tmpFileName.AppendDir( wxT( "modules" ) );
+        tmpFileName.AppendDir( "modules" );
         envVarItem.SetDefinedExternally( false );
     }
 
@@ -380,7 +381,7 @@ bool PGM_BASE::InitPgm()
     }
     else
     {
-        tmpFileName.AppendDir( wxT( "packages3d" ) );
+        tmpFileName.AppendDir( "packages3d" );
         envVarItem.SetDefinedExternally( false );
     }
 
@@ -413,7 +414,8 @@ bool PGM_BASE::InitPgm()
             // Only add path if exists and can be read by the user.
             if( fn.DirExists() && fn.IsDirReadable() )
             {
-                wxLogDebug( "Checking template path '%s' exists", fn.GetPath() );
+                wxLogTrace( tracePathsAndFiles, "Checking template path '%s' exists",
+                            fn.GetPath() );
                 templatePaths.AddPaths( fn.GetPath() );
             }
         }
@@ -466,7 +468,7 @@ bool PGM_BASE::InitPgm()
     else
     {
         tmpFileName = baseSharePath;
-        tmpFileName.AppendDir( wxT( "library" ) );
+        tmpFileName.AppendDir( "library" );
         envVarItem.SetDefinedExternally( false );
     }
 
@@ -590,7 +592,7 @@ void PGM_BASE::loadCommonSettings()
         }
     }
 
-    m_editor_name = m_common_settings->Read( wxT( "Editor" ) );
+    m_editor_name = m_common_settings->Read( "Editor" );
 
     wxString entry, oldPath;
     wxArrayString entries;
@@ -602,7 +604,7 @@ void PGM_BASE::loadCommonSettings()
     while( m_common_settings->GetNextEntry( entry, index ) )
     {
         wxLogTrace( traceEnvVars,
-                    wxT( "Enumerating over entry %s, %ld." ), GetChars( entry ), index );
+                    "Enumerating over entry %s, %ld.", GetChars( entry ), index );
         entries.Add( entry );
     }
 
@@ -642,12 +644,12 @@ void PGM_BASE::SaveCommonSettings()
             if( it->second.GetDefinedExternally() )
                 continue;
 
-            wxLogTrace( traceEnvVars, wxT( "Saving environment variable config entry %s as %s" ),
+            wxLogTrace( traceEnvVars, "Saving environment variable config entry %s as %s",
                         GetChars( it->first ),  GetChars( it->second.GetValue() ) );
             m_common_settings->Write( it->first, it->second.GetValue() );
         }
 
-        m_common_settings->SetPath( wxT( ".." ) );
+        m_common_settings->SetPath( ".." );
     }
 }
 
@@ -677,14 +679,14 @@ bool PGM_BASE::SetLanguage( bool first_time )
     }
 
     // dictionary file name without extend (full name is kicad.mo)
-    wxString dictionaryName( wxT( "kicad" ) );
+    wxString dictionaryName( "kicad" );
 
     delete m_locale;
     m_locale = new wxLocale;
 
     if( !m_locale->Init( m_language_id ) )
     {
-        wxLogDebug( wxT( "This language is not supported by the system." ) );
+        wxLogTrace( traceLocale, "This language is not supported by the system." );
 
         setLanguageId( wxLANGUAGE_DEFAULT );
         delete m_locale;
@@ -695,7 +697,7 @@ bool PGM_BASE::SetLanguage( bool first_time )
     }
     else if( !first_time )
     {
-        wxLogDebug( wxT( "Search for dictionary %s.mo in %s" ),
+        wxLogTrace( traceLocale, "Search for dictionary %s.mo in %s",
                     GetChars( dictionaryName ), GetChars( m_locale->GetName() ) );
     }
 
@@ -746,7 +748,7 @@ bool PGM_BASE::SetLanguage( bool first_time )
 
 void PGM_BASE::SetLanguageIdentifier( int menu_id )
 {
-    wxLogDebug( wxT( "Select language ID %d from %d possible languages." ),
+    wxLogTrace( traceLocale, "Select language ID %d from %d possible languages.",
                 menu_id, DIM( s_Languages ) );
 
     for( unsigned ii = 0; ii < DIM( s_Languages ); ii++ )
@@ -772,23 +774,23 @@ void PGM_BASE::SetLanguagePath()
         wxFileName fn( guesses[i], wxEmptyString );
 
         // Append path for Windows and unix KiCad package install
-        fn.AppendDir( wxT( "share" ) );
-        fn.AppendDir( wxT( "internat" ) );
+        fn.AppendDir( "share" );
+        fn.AppendDir( "internat" );
 
         if( fn.IsDirReadable() )
         {
-            wxLogDebug( wxT( "Adding locale lookup path: " ) + fn.GetPath() );
+            wxLogTrace( traceLocale, "Adding locale lookup path: " + fn.GetPath() );
             wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
         }
 
         // Append path for unix standard install
         fn.RemoveLastDir();
-        fn.AppendDir( wxT( "kicad" ) );
-        fn.AppendDir( wxT( "internat" ) );
+        fn.AppendDir( "kicad" );
+        fn.AppendDir( "internat" );
 
         if( fn.IsDirReadable() )
         {
-            wxLogDebug( wxT( "Adding locale lookup path: " ) + fn.GetPath() );
+            wxLogTrace( traceLocale, "Adding locale lookup path: " + fn.GetPath() );
             wxLocale::AddCatalogLookupPathPrefix( fn.GetPath() );
         }
     }
@@ -843,12 +845,12 @@ bool PGM_BASE::SetLocalEnvVariable( const wxString& aName, const wxString& aValu
     // Check to see if the environment variable is already set.
     if( wxGetEnv( aName, &env ) )
     {
-        wxLogTrace( traceEnvVars, wxT( "Environment variable %s already set to %s." ),
+        wxLogTrace( traceEnvVars,  "Environment variable %s already set to %s.",
                     GetChars( aName ), GetChars( env ) );
         return env == aValue;
     }
 
-    wxLogTrace( traceEnvVars, wxT( "Setting local environment variable %s to %s." ),
+    wxLogTrace( traceEnvVars, "Setting local environment variable %s to %s.",
                 GetChars( aName ), GetChars( aValue ) );
 
     return wxSetEnv( aName, aValue );
@@ -869,7 +871,7 @@ void PGM_BASE::SetLocalEnvVariables( const ENV_VAR_MAP& aEnvVarMap )
     // is run.
     for( ENV_VAR_MAP_ITER it = m_local_env_vars.begin(); it != m_local_env_vars.end(); ++it )
     {
-        wxLogTrace( traceEnvVars, wxT( "Setting local environment variable %s to %s." ),
+        wxLogTrace( traceEnvVars, "Setting local environment variable %s to %s.",
                     GetChars( it->first ), GetChars( it->second.GetValue() ) );
         wxSetEnv( it->first, it->second.GetValue() );
     }
diff --git a/common/search_stack.cpp b/common/search_stack.cpp
index 6c96c3fa5c..3cfa3c4eda 100644
--- a/common/search_stack.cpp
+++ b/common/search_stack.cpp
@@ -2,7 +2,7 @@
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
  * Copyright (C) 2014 CERN
- * Copyright (C) 2014-2015 KiCad Developers, see CHANGELOG.TXT for contributors.
+ * Copyright (C) 2014-2018 KiCad Developers, see CHANGELOG.TXT for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -24,9 +24,9 @@
 
 #include <macros.h>
 #include <search_stack.h>
+#include <trace_helpers.h>
 #include <wx/tokenzr.h>
 
-
 #if defined(__MINGW32__)
  #define PATH_SEPS          wxT( ";\r\n" )
 #else
@@ -200,11 +200,11 @@ const wxString SEARCH_STACK::LastVisitedPath( const wxString& aSubPathToSearch )
 #if defined(DEBUG)
 void SEARCH_STACK::Show( const wxString& aPrefix ) const
 {
-    wxLogDebug( wxT( "%s SEARCH_STACK:" ), GetChars( aPrefix ) );
+    wxLogTrace( tracePathsAndFiles, "%s SEARCH_STACK:", aPrefix );
 
     for( unsigned i=0;  i<GetCount();  ++i )
     {
-        wxLogDebug( wxT( "  [%2u]:%s" ), i, TO_UTF8( (*this)[i] ) );
+        wxLogTrace( tracePathsAndFiles, "  [%2u]:%s", i, TO_UTF8( (*this)[i] ) );
     }
 }
 #endif
diff --git a/common/searchhelpfilefullpath.cpp b/common/searchhelpfilefullpath.cpp
index 89122ba959..64636dbeff 100644
--- a/common/searchhelpfilefullpath.cpp
+++ b/common/searchhelpfilefullpath.cpp
@@ -2,7 +2,7 @@
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
  * Copyright (C) 2014-2015 CERN
- * Copyright (C) 2014-2015 KiCad Developers, see CHANGELOG.TXT for contributors.
+ * Copyright (C) 2014-2018 KiCad Developers, see CHANGELOG.TXT for contributors.
  * @author Maciej Suminski <maciej.suminski@cern.ch>
  *
  * This program is free software; you can redistribute it and/or
@@ -27,6 +27,7 @@
 #include <common.h>
 #include <config.h>     // to define DEFAULT_INSTALL_PATH
 #include <macros.h>
+#include <trace_helpers.h>
 
 
 /**
@@ -50,7 +51,7 @@ wxString FindFileInSearchPaths( const SEARCH_STACK& aStack,
                 fn.AppendDir( (*aSubdirs)[j] );
         }
 
-        wxLogDebug( wxT( "    %s" ), GetChars( fn.GetFullPath() ) );
+        wxLogTrace( tracePathsAndFiles, "    %s", fn.GetFullPath() );
 
         if( fn.DirExists() )
         {
@@ -85,10 +86,10 @@ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aB
     // and in Contents/SharedSupport/help inside the
     // bundle.
     // Below we account for an international subdirectory.
-    subdirs.Add( wxT( "help" ) );
-    altsubdirs.Add( wxT( "Contents" ) );
-    altsubdirs.Add( wxT( "SharedSupport" ) );
-    altsubdirs.Add( wxT( "help" ) );
+    subdirs.Add( "help" );
+    altsubdirs.Add( "Contents" );
+    altsubdirs.Add( "SharedSupport" );
+    altsubdirs.Add( "help" );
 #endif
 
 #if ! defined(__WXMAC__) // && defined(__linux__)
@@ -105,17 +106,17 @@ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aB
     // installed into "<CMAKE_INSTALL_PREFIX>/share/doc/kicad/help" for linux.
     // This is ${KICAD_HELP} var in that CMakeLists.txt file.
     // Below we account for an international subdirectory.
-    subdirs.Add( wxT( "share" ) );
-    subdirs.Add( wxT( "doc" ) );
-    subdirs.Add( wxT( "kicad" ) );
-    subdirs.Add( wxT( "help" ) );
+    subdirs.Add( "share" );
+    subdirs.Add( "doc" );
+    subdirs.Add( "kicad" );
+    subdirs.Add( "help" );
 
     // Based on kicad-doc.bzr/CMakeLists.txt, line 35, the help files are
     // installed into "<CMAKE_INSTALL_PREFIX>/doc/help" for Windows.
     // This is ${KICAD_HELP} var in that CMakeLists.txt file.
     // Below we account for an international subdirectory.
-    altsubdirs.Add( wxT( "doc" ) );
-    altsubdirs.Add( wxT( "help" ) );
+    altsubdirs.Add( "doc" );
+    altsubdirs.Add( "help" );
 #endif
 
     // If there's a KICAD environment variable set, always use that guy's path first.
@@ -140,14 +141,14 @@ wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aB
 
     // wxLocale::GetName() does not return always the short name
     locale_name_dirs.Add( i18n->GetName().BeforeLast( '_' ) );  // short canonical name like fr
-    locale_name_dirs.Add( wxT( "en" ) );                        // default (en)
+    locale_name_dirs.Add( "en" );                        // default (en)
 
 #if defined(DEBUG) && 1
     ss.Show( wxString( __func__ ) );
-    wxLogDebug( wxT( "%s: m_help_file:'%s'" ), __func__, GetChars( aBaseName ) );
+    wxLogTrace( tracePathsAndFiles, "%s: m_help_file:'%s'", __func__, aBaseName );
 #endif
 
-    wxLogDebug( wxT( "Checking SEARCH_STACK for file %s" ), GetChars( aBaseName ) );
+    wxLogTrace( tracePathsAndFiles, "Checking SEARCH_STACK for file %s", aBaseName );
 
     // Help files can be html (.html ext) or pdf (.pdf ext) files.
     // Therefore, <BaseName>.html file is searched and if not found,
diff --git a/common/trace_helpers.cpp b/common/trace_helpers.cpp
index e3f3616a24..8586ef3561 100644
--- a/common/trace_helpers.cpp
+++ b/common/trace_helpers.cpp
@@ -46,6 +46,8 @@ const wxChar* const traceKicadPcbPlugin = wxT( "KICAD_PCB_PLUGIN" );
 const wxChar* const tracePrinting = wxT( "KICAD_PRINT" );
 const wxChar* const traceAutoSave = wxT( "KICAD_AUTOSAVE" );
 const wxChar* const tracePathsAndFiles = wxT( "KICAD_PATHS_AND_FILES" );
+const wxChar* const traceLocale = wxT( "KICAD_LOCALE" );
+const wxChar* const traceScreen = wxT( "KICAD_SCREEN" );
 
 
 wxString dump( const wxArrayString& aArray )
diff --git a/include/trace_helpers.h b/include/trace_helpers.h
index f416c55cbd..115d87d800 100644
--- a/include/trace_helpers.h
+++ b/include/trace_helpers.h
@@ -99,6 +99,16 @@ extern const wxChar* const tracePrinting;
  */
 extern const wxChar* const tracePathsAndFiles;
 
+/**
+ * Flag to enable locale debug output.
+ */
+extern const wxChar* const traceLocale;
+
+/**
+ * Flag to enable debug output of #BASE_SCREEN and it's derivatives.
+ */
+extern const wxChar* const traceScreen;
+
 ///@}
 
 /**
diff --git a/kicad/tree_project_frame.cpp b/kicad/tree_project_frame.cpp
index eebabe184d..8a1f61a4e8 100644
--- a/kicad/tree_project_frame.cpp
+++ b/kicad/tree_project_frame.cpp
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  * Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
- * Copyright (C) 1992-2017 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -38,6 +38,7 @@
 #include <bitmaps.h>
 #include <gestfich.h>
 #include <menus_helpers.h>
+#include <trace_helpers.h>
 #include <wildcards_and_files_ext.h>
 
 #include "treeproject_item.h"
@@ -476,6 +477,7 @@ bool TREE_PROJECT_FRAME::AddItemToTreeProject( const wxString& aName,
             wxString    fullFileName = aName.BeforeLast( '.' );
             wxString    rootName;
             TREEPROJECT_ITEM* itemData = GetItemIdData( m_root );
+
             if( itemData )
                 rootName = itemData->GetFileName().BeforeLast( '.' );
 
@@ -691,48 +693,49 @@ void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
 
     switch( tree_id )
     {
-        case TREE_PROJECT:
-            // Add a swith to an other project option only if the selected item
-            // is not the root item (current project)
-            if( curr_item != m_TreeProject->GetRootItem() )
-            {
-                AddMenuItem( &popupMenu, ID_PROJECT_SWITCH_TO_OTHER,
-                             _( "&Switch to this Project" ),
-                             _( "Close all editors, and switch to the selected project" ),
-                             KiBitmap( open_project_xpm ) );
-                popupMenu.AppendSeparator();
-            }
-            AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
-                         _( "New D&irectory..." ),
-                         _( "Create a New Directory" ),
-                         KiBitmap( directory_xpm ) );
-            break;
+    case TREE_PROJECT:
+        // Add a swith to an other project option only if the selected item
+        // is not the root item (current project)
+        if( curr_item != m_TreeProject->GetRootItem() )
+        {
+            AddMenuItem( &popupMenu, ID_PROJECT_SWITCH_TO_OTHER,
+                         _( "&Switch to this Project" ),
+                         _( "Close all editors, and switch to the selected project" ),
+                         KiBitmap( open_project_xpm ) );
+            popupMenu.AppendSeparator();
+        }
 
-        case TREE_DIRECTORY:
-            AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
-                         _( "New D&irectory..." ),
-                         _( "Create a New Directory" ),
-                         KiBitmap( directory_xpm ) );
-            AddMenuItem( &popupMenu,  ID_PROJECT_DELETE,
-                         _( "&Delete Directory" ),
-                         _( "Delete the Directory and its content" ),
-                         KiBitmap( delete_xpm ) );
-            break;
+        AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
+                     _( "New D&irectory..." ),
+                     _( "Create a New Directory" ),
+                     KiBitmap( directory_xpm ) );
+        break;
 
-        default:
-            AddMenuItem( &popupMenu, ID_PROJECT_TXTEDIT,
-                         _( "&Edit in a Text Editor" ),
-                         _( "Open the file in a Text Editor" ),
-                         KiBitmap( editor_xpm ) );
-            AddMenuItem( &popupMenu, ID_PROJECT_RENAME,
-                         _( "&Rename File..." ),
-                         _( "Rename file" ),
-                         KiBitmap( right_xpm ) );
-            AddMenuItem( &popupMenu,  ID_PROJECT_DELETE,
-                         _( "&Delete File" ),
-                         _( "Delete the Directory and its content" ),
-                         KiBitmap( delete_xpm ) );
-            break;
+    case TREE_DIRECTORY:
+        AddMenuItem( &popupMenu, ID_PROJECT_NEWDIR,
+                     _( "New D&irectory..." ),
+                     _( "Create a New Directory" ),
+                     KiBitmap( directory_xpm ) );
+        AddMenuItem( &popupMenu,  ID_PROJECT_DELETE,
+                     _( "&Delete Directory" ),
+                     _( "Delete the Directory and its content" ),
+                     KiBitmap( delete_xpm ) );
+        break;
+
+    default:
+        AddMenuItem( &popupMenu, ID_PROJECT_TXTEDIT,
+                     _( "&Edit in a Text Editor" ),
+                     _( "Open the file in a Text Editor" ),
+                     KiBitmap( editor_xpm ) );
+        AddMenuItem( &popupMenu, ID_PROJECT_RENAME,
+                     _( "&Rename File..." ),
+                     _( "Rename file" ),
+                     KiBitmap( right_xpm ) );
+        AddMenuItem( &popupMenu,  ID_PROJECT_DELETE,
+                     _( "&Delete File" ),
+                     _( "Delete the Directory and its content" ),
+                     KiBitmap( delete_xpm ) );
+        break;
     }
 
     PopupMenu( &popupMenu );
@@ -1083,7 +1086,7 @@ void TREE_PROJECT_FRAME::FileWatcherReset()
             // we can see wxString under a debugger, not a wxFileName
             const wxString& path = itemData->GetFileName();
 
-            wxLogDebug( "%s: add '%s'\n", __func__, TO_UTF8( path ) );
+            wxLogTrace( traceFilesAndPaths, "%s: add '%s'\n", __func__, TO_UTF8( path ) );
 
             if( wxFileName::IsDirReadable( path ) )     // linux whines about watching protected dir
             {
@@ -1103,10 +1106,10 @@ void TREE_PROJECT_FRAME::FileWatcherReset()
 #if defined(DEBUG) && 1
     wxArrayString paths;
     m_watcher->GetWatchedPaths( &paths );
-    wxLogDebug( "%s: watched paths:", __func__ );
+    wxLogTrace( tracePathsAndFiles, "%s: watched paths:", __func__ );
 
     for( unsigned ii = 0; ii < paths.GetCount(); ii++ )
-        wxLogDebug( " %s\n", TO_UTF8( paths[ii] ) );
+        wxLogTrace( tracePathsAndFiles, " %s\n", TO_UTF8( paths[ii] ) );
 #endif
 }