From 6850e23fe0f2b7252afd3829eeabf74387e714f3 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Mon, 30 Apr 2018 15:17:34 -0400 Subject: [PATCH] Replace printf debugging output in common/project.cpp with wxLogTrace. --- common/project.cpp | 23 ++++++++++++++--------- common/trace_helpers.cpp | 1 + include/trace_helpers.h | 5 +++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/common/project.cpp b/common/project.cpp index 48b9afb8ea..052406f607 100644 --- a/common/project.cpp +++ b/common/project.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2014-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 @@ -35,6 +35,7 @@ #include #include #include +#include PROJECT::PROJECT() @@ -72,7 +73,8 @@ void PROJECT::SetProjectFullName( const wxString& aFullPathAndName ) { Clear(); // clear the data when the project changes. - DBG(printf( "%s: old:'%s' new:'%s'\n", __func__, TO_UTF8( GetProjectFullName() ), TO_UTF8( aFullPathAndName ) );) + wxLogTrace( tracePathsAndFiles, "%s: old:'%s' new:'%s'", __func__, + TO_UTF8( GetProjectFullName() ), TO_UTF8( aFullPathAndName ) ); m_project_name = aFullPathAndName; @@ -126,8 +128,6 @@ const wxString PROJECT::libTableName( const wxString& aLibTableName ) const wxFileName fn = GetProjectFullName(); wxString path = fn.GetPath(); - // DBG(printf( "path:'%s' fn:'%s'\n", TO_UTF8(path), TO_UTF8(fn.GetFullPath()) );) - // if there's no path to the project name, or the name as a whole is bogus or its not // write-able then use a template file. if( !fn.GetDirCount() || !fn.IsOk() || !wxFileName::IsDirWritable( path ) ) @@ -236,7 +236,7 @@ static bool copy_pro_file_template( const SEARCH_STACK& aSearchS, const wxString { if( aDestination.IsEmpty() ) { - DBG( printf( "%s: destination is empty.\n", __func__ );) + wxLogTrace( tracePathsAndFiles, "%s: destination is empty.", __func__ ); return false; } @@ -246,7 +246,8 @@ static bool copy_pro_file_template( const SEARCH_STACK& aSearchS, const wxString if( !kicad_pro_template ) { - DBG( printf( "%s: template file '%s' not found using search paths.\n", __func__, TO_UTF8( templateFile ) );) + wxLogTrace( tracePathsAndFiles, "%s: template file '%s' not found using search paths.", + __func__, TO_UTF8( templateFile ) ); wxFileName templ( wxStandardPaths::Get().GetDocumentsDir(), wxT( "kicad" ), ProjectFileExtension ); @@ -265,7 +266,8 @@ static bool copy_pro_file_template( const SEARCH_STACK& aSearchS, const wxString kicad_pro_template = templ.GetFullPath(); } - DBG( printf( "%s: using template file '%s' as project file.\n", __func__, TO_UTF8( kicad_pro_template ) );) + wxLogTrace( tracePathsAndFiles, "%s: using template file '%s' as project file.", + __func__, TO_UTF8( kicad_pro_template ) ); // Verify aDestination can be created. if this is not the case, wxCopyFile // will generate a crappy log error message, and we *do not want* this kind @@ -351,7 +353,8 @@ void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aGroupName bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aGroupName, const PARAM_CFG_ARRAY& aParams, const wxString& aForeignProjectFileName ) { - std::unique_ptr cfg( configCreate( aSList, aGroupName, aForeignProjectFileName ) ); + std::unique_ptr cfg( configCreate( aSList, aGroupName, + aForeignProjectFileName ) ); if( !cfg.get() ) { @@ -407,6 +410,7 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs( KIWAY& aKiway ) // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may // stack this way, all using the same global fallback table. KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB ); + if( kiface ) tbl = (FP_LIB_TABLE*) kiface->IfaceOrAddress( KIFACE_G_FOOTPRINT_TABLE ); @@ -421,7 +425,8 @@ FP_LIB_TABLE* PROJECT::PcbFootprintLibs( KIWAY& aKiway ) } catch( const IO_ERROR& ioe ) { - DisplayErrorMessage( NULL, _( "Error loading project footprint library table" ), ioe.What() ); + DisplayErrorMessage( NULL, _( "Error loading project footprint library table" ), + ioe.What() ); } } diff --git a/common/trace_helpers.cpp b/common/trace_helpers.cpp index 5b6ea28a53..e3f3616a24 100644 --- a/common/trace_helpers.cpp +++ b/common/trace_helpers.cpp @@ -45,6 +45,7 @@ const wxChar* const traceGedaPcbPlugin = wxT( "KICAD_GEDA_PLUGIN" ); 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" ); wxString dump( const wxArrayString& aArray ) diff --git a/include/trace_helpers.h b/include/trace_helpers.h index ab8b043ab1..f416c55cbd 100644 --- a/include/trace_helpers.h +++ b/include/trace_helpers.h @@ -94,6 +94,11 @@ extern const wxChar* const traceGedaPcbPlugin; */ extern const wxChar* const tracePrinting; +/** + * Flag to enable path and file name debug output. + */ +extern const wxChar* const tracePathsAndFiles; + ///@} /**