Remove the wxLog calls from math/util.h for now

This was leaking windows headers and partial wx headers to 1084 compilation units......
This also means math/util.h is leaking to 1084 compilation units which seems a bit high too.
This commit is contained in:
Marek Roszko 2021-06-01 01:17:57 -04:00
parent cfa2b57c68
commit cf2bb5692a
39 changed files with 180 additions and 65 deletions

View File

@ -31,6 +31,7 @@
#include <drawing_sheet/ds_painter.h> #include <drawing_sheet/ds_painter.h>
#include <drawing_sheet/drawing_sheet_reader_lexer.h> #include <drawing_sheet/drawing_sheet_reader_lexer.h>
#include <wx/ffile.h> #include <wx/ffile.h>
#include <wx/log.h>
#include <wx/file.h> #include <wx/file.h>
#include <wx/mstream.h> #include <wx/mstream.h>

View File

@ -30,6 +30,7 @@
#include <trace_helpers.h> #include <trace_helpers.h>
#include <trigo.h> #include <trigo.h>
#include <i18n_utility.h> #include <i18n_utility.h>
#include <wx/log.h>
#include <wx/fdrepdlg.h> #include <wx/fdrepdlg.h>

View File

@ -38,6 +38,7 @@
#include <cassert> #include <cassert>
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
#include <wx/log.h>
using namespace KIGFX; using namespace KIGFX;

View File

@ -24,6 +24,7 @@
#include <algorithm> #include <algorithm>
#include <kicad_string.h> #include <kicad_string.h>
#include <wx/log.h>
#ifdef DEBUG #ifdef DEBUG
#include <cstdarg> #include <cstdarg>

View File

@ -29,6 +29,7 @@
#include <kicad_string.h> #include <kicad_string.h>
#include <richio.h> #include <richio.h>
#include <wx/log.h>
#include <functional> #include <functional>
#include <cstdio> #include <cstdio>

View File

@ -21,6 +21,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#include <wx/log.h>
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <config_params.h> #include <config_params.h>

View File

@ -23,6 +23,7 @@
#include <settings/color_settings.h> #include <settings/color_settings.h>
#include <settings/parameters.h> #include <settings/parameters.h>
#include <settings/settings_manager.h> #include <settings/settings_manager.h>
#include <wx/log.h>
#include "builtin_color_themes.h" #include "builtin_color_themes.h"

View File

@ -33,6 +33,7 @@
#include <wx/debug.h> #include <wx/debug.h>
#include <wx/fileconf.h> #include <wx/fileconf.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/log.h>
#include <wx/wfstream.h> #include <wx/wfstream.h>

View File

@ -138,6 +138,7 @@ set( EESCHEMA_WIDGETS
set ( EESCHEMA_LIBEDIT_SRCS set ( EESCHEMA_LIBEDIT_SRCS
symbol_editor/lib_logger.cpp
symbol_editor/symbol_editor.cpp symbol_editor/symbol_editor.cpp
symbol_editor/symbol_editor_plotter.cpp symbol_editor/symbol_editor_plotter.cpp
symbol_editor/symbol_editor_settings.cpp symbol_editor/symbol_editor_settings.cpp

View File

@ -23,7 +23,7 @@
#include <template_fieldnames.h> #include <template_fieldnames.h>
#include <lib_symbol.h> #include <lib_symbol.h>
#include <symbol_lib_table.h> #include <symbol_lib_table.h>
#include <wx/log.h>
static const wxString DescriptionFormat = static const wxString DescriptionFormat =
"<b>__NAME__</b>" "<b>__NAME__</b>"

View File

@ -27,6 +27,8 @@
#include <convert_to_biu.h> #include <convert_to_biu.h>
#include <ki_exception.h> #include <ki_exception.h>
#include <wx/log.h>
#include "plugins/altium/altium_parser.h" #include "plugins/altium/altium_parser.h"
#include "sch_plugins/altium/altium_parser_sch.h" #include "sch_plugins/altium/altium_parser_sch.h"

View File

@ -28,6 +28,7 @@
#include <wx/mstream.h> #include <wx/mstream.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/log.h>
#include <wx/textfile.h> #include <wx/textfile.h>
#include <wx/tokenzr.h> #include <wx/tokenzr.h>

View File

@ -37,6 +37,7 @@
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/log.h>
#include "erc_item.h" #include "erc_item.h"

View File

@ -81,7 +81,7 @@ public:
case LABEL_SPIN_STYLE::UP: newSpin = LABEL_SPIN_STYLE::RIGHT; break; case LABEL_SPIN_STYLE::UP: newSpin = LABEL_SPIN_STYLE::RIGHT; break;
case LABEL_SPIN_STYLE::RIGHT: newSpin = LABEL_SPIN_STYLE::BOTTOM; break; case LABEL_SPIN_STYLE::RIGHT: newSpin = LABEL_SPIN_STYLE::BOTTOM; break;
case LABEL_SPIN_STYLE::BOTTOM: newSpin = LABEL_SPIN_STYLE::LEFT; break; case LABEL_SPIN_STYLE::BOTTOM: newSpin = LABEL_SPIN_STYLE::LEFT; break;
default: wxLogWarning( "RotateCCW encountered unknown current spin style" ); break; default: break;
} }
return LABEL_SPIN_STYLE( newSpin ); return LABEL_SPIN_STYLE( newSpin );
@ -97,7 +97,7 @@ public:
case LABEL_SPIN_STYLE::BOTTOM: newSpin = LABEL_SPIN_STYLE::RIGHT; break; case LABEL_SPIN_STYLE::BOTTOM: newSpin = LABEL_SPIN_STYLE::RIGHT; break;
case LABEL_SPIN_STYLE::RIGHT: newSpin = LABEL_SPIN_STYLE::UP; break; case LABEL_SPIN_STYLE::RIGHT: newSpin = LABEL_SPIN_STYLE::UP; break;
case LABEL_SPIN_STYLE::UP: newSpin = LABEL_SPIN_STYLE::LEFT; break; case LABEL_SPIN_STYLE::UP: newSpin = LABEL_SPIN_STYLE::LEFT; break;
default: wxLogWarning( "RotateCCW encountered unknown current spin style" ); break; default: break;
} }
return LABEL_SPIN_STYLE( newSpin ); return LABEL_SPIN_STYLE( newSpin );
@ -116,7 +116,7 @@ public:
case LABEL_SPIN_STYLE::BOTTOM: newSpin = LABEL_SPIN_STYLE::UP; break; case LABEL_SPIN_STYLE::BOTTOM: newSpin = LABEL_SPIN_STYLE::UP; break;
case LABEL_SPIN_STYLE::LEFT: break; case LABEL_SPIN_STYLE::LEFT: break;
case LABEL_SPIN_STYLE::RIGHT: break; case LABEL_SPIN_STYLE::RIGHT: break;
default: wxLogWarning( "MirrorVertically encountered unknown current spin style" ); break; default: break;
} }
return LABEL_SPIN_STYLE( newSpin ); return LABEL_SPIN_STYLE( newSpin );
@ -135,7 +135,7 @@ public:
case LABEL_SPIN_STYLE::RIGHT: newSpin = LABEL_SPIN_STYLE::LEFT; break; case LABEL_SPIN_STYLE::RIGHT: newSpin = LABEL_SPIN_STYLE::LEFT; break;
case LABEL_SPIN_STYLE::UP: break; case LABEL_SPIN_STYLE::UP: break;
case LABEL_SPIN_STYLE::BOTTOM: break; case LABEL_SPIN_STYLE::BOTTOM: break;
default: wxLogWarning( "MirrorHorizontally encountered unknown current spin style" ); break; default: break;
} }
return LABEL_SPIN_STYLE( newSpin ); return LABEL_SPIN_STYLE( newSpin );

View File

@ -0,0 +1,68 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 CERN
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* https://www.gnu.org/licenses/gpl-3.0.html
* or you may search the http://www.gnu.org website for the version 3 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <wx/intl.h>
#include <lib_logger.h>
LIB_LOGGER::LIB_LOGGER() : m_previousLogger( nullptr ), m_activated( false )
{
}
LIB_LOGGER::~LIB_LOGGER()
{
Deactivate();
}
void LIB_LOGGER::Activate()
{
if( !m_activated )
{
m_previousLogger = wxLog::GetActiveTarget();
wxLog::SetActiveTarget( this );
m_activated = true;
}
}
void LIB_LOGGER::Deactivate()
{
if( m_activated )
{
Flush();
m_activated = false;
wxLog::SetActiveTarget( m_previousLogger );
}
}
void LIB_LOGGER::Flush()
{
if( m_bHasMessages )
{
wxLogMessage( _( "Not all symbol libraries could be loaded. Use the Manage Symbol\n"
"Libraries dialog to adjust paths and add or remove libraries." ) );
wxLogGui::Flush();
}
}

View File

@ -0,0 +1,50 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 CERN
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* https://www.gnu.org/licenses/gpl-3.0.html
* or you may search the http://www.gnu.org website for the version 3 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef LIB_LOGGER_H
#define LIB_LOGGER_H
#include <wx/log.h>
class LIB_LOGGER : public wxLogGui
{
public:
LIB_LOGGER();
~LIB_LOGGER() override;
void Activate();
void Deactivate();
void Flush() override;
private:
wxLog* m_previousLogger;
bool m_activated;
};
#endif /* LIB_LOGGER_H */

View File

@ -38,6 +38,8 @@
#include <widgets/progress_reporter.h> #include <widgets/progress_reporter.h>
#include <list> #include <list>
#include <locale_io.h> #include <locale_io.h>
#include <wx/log.h>
#include "lib_logger.h"
SYMBOL_LIBRARY_MANAGER::SYMBOL_LIBRARY_MANAGER( SYMBOL_EDIT_FRAME& aFrame ) : SYMBOL_LIBRARY_MANAGER::SYMBOL_LIBRARY_MANAGER( SYMBOL_EDIT_FRAME& aFrame ) :
@ -46,6 +48,13 @@ SYMBOL_LIBRARY_MANAGER::SYMBOL_LIBRARY_MANAGER( SYMBOL_EDIT_FRAME& aFrame ) :
{ {
m_adapter = SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( &m_frame, this ); m_adapter = SYMBOL_TREE_SYNCHRONIZING_ADAPTER::Create( &m_frame, this );
m_adapter->ShowUnits( false ); m_adapter->ShowUnits( false );
m_logger = new LIB_LOGGER();
}
SYMBOL_LIBRARY_MANAGER::~SYMBOL_LIBRARY_MANAGER()
{
delete m_logger;
} }
@ -53,12 +62,12 @@ void SYMBOL_LIBRARY_MANAGER::Sync( const wxString& aForceRefresh,
std::function<void( int, int, std::function<void( int, int,
const wxString& )> aProgressCallback ) const wxString& )> aProgressCallback )
{ {
m_logger.Activate(); m_logger->Activate();
{ {
getAdapter()->Sync( aForceRefresh, aProgressCallback ); getAdapter()->Sync( aForceRefresh, aProgressCallback );
m_syncHash = symTable()->GetModifyHash(); m_syncHash = symTable()->GetModifyHash();
} }
m_logger.Deactivate(); m_logger->Deactivate();
} }

View File

@ -44,55 +44,7 @@ class SCH_PLUGIN;
class SYMBOL_EDIT_FRAME; class SYMBOL_EDIT_FRAME;
class SYMBOL_LIB_TABLE; class SYMBOL_LIB_TABLE;
class SYMBOL_LIB_TABLE_ROW; class SYMBOL_LIB_TABLE_ROW;
class LIB_LOGGER;
class LIB_LOGGER : public wxLogGui
{
public:
LIB_LOGGER() :
m_previousLogger( nullptr ),
m_activated( false )
{ }
~LIB_LOGGER() override
{
Deactivate();
}
void Activate()
{
if( !m_activated )
{
m_previousLogger = wxLog::GetActiveTarget();
wxLog::SetActiveTarget( this );
m_activated = true;
}
}
void Deactivate()
{
if( m_activated )
{
Flush();
m_activated = false;
wxLog::SetActiveTarget( m_previousLogger );
}
}
void Flush() override
{
if( m_bHasMessages )
{
wxLogMessage( _( "Not all symbol libraries could be loaded. Use the Manage Symbol\n"
"Libraries dialog to adjust paths and add or remove libraries." ) );
wxLogGui::Flush();
}
}
private:
wxLog* m_previousLogger;
bool m_activated;
};
/** /**
@ -102,6 +54,7 @@ class SYMBOL_LIBRARY_MANAGER
{ {
public: public:
SYMBOL_LIBRARY_MANAGER( SYMBOL_EDIT_FRAME& aFrame ); SYMBOL_LIBRARY_MANAGER( SYMBOL_EDIT_FRAME& aFrame );
~SYMBOL_LIBRARY_MANAGER();
/** /**
* Updates the #SYMBOL_LIBRARY_MANAGER data to synchronize with Symbol Library Table. * Updates the #SYMBOL_LIBRARY_MANAGER data to synchronize with Symbol Library Table.
@ -469,7 +422,7 @@ private:
std::map<wxString, LIB_BUFFER> m_libs; std::map<wxString, LIB_BUFFER> m_libs;
SYMBOL_EDIT_FRAME& m_frame; ///< Parent frame SYMBOL_EDIT_FRAME& m_frame; ///< Parent frame
LIB_LOGGER m_logger; LIB_LOGGER* m_logger;
int m_syncHash; ///< Symbol lib table hash value from last synchronization int m_syncHash; ///< Symbol lib table hash value from last synchronization
wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter; wxObjectDataPtr<LIB_TREE_MODEL_ADAPTER> m_adapter;

View File

@ -114,7 +114,6 @@ public:
} }
catch( ... ) catch( ... )
{ {
wxLogTrace( traceSettings, "Unable to create application settings object" );
} }
} }

View File

@ -30,8 +30,6 @@
#include <cstdint> #include <cstdint>
#include <limits> #include <limits>
#include <typeinfo> #include <typeinfo>
#include <wx/debug.h>
#include <wx/log.h>
/** /**
* Function Clamp * Function Clamp
@ -45,7 +43,6 @@
*/ */
template <typename T> inline const T& Clamp( const T& lower, const T& value, const T& upper ) template <typename T> inline const T& Clamp( const T& lower, const T& value, const T& upper )
{ {
wxASSERT( lower <= upper );
if( value < lower ) if( value < lower )
return lower; return lower;
else if( upper < value ) else if( upper < value )
@ -73,8 +70,6 @@ constexpr ret_type KiROUND( fp_type v )
if( std::numeric_limits<ret_type>::max() < ret || if( std::numeric_limits<ret_type>::max() < ret ||
std::numeric_limits<ret_type>::lowest() > ret ) std::numeric_limits<ret_type>::lowest() > ret )
{ {
wxLogDebug
( "Overflow KiROUND converting value %f to %s", double( v ), typeid(ret_type).name() );
return 0; return 0;
} }

View File

@ -29,6 +29,8 @@
#include <geometry/geometry_utils.h> #include <geometry/geometry_utils.h>
#include <board_commit.h> #include <board_commit.h>
#include <wx/log.h>
#include <thread> #include <thread>
#include <mutex> #include <mutex>
#include <algorithm> #include <algorithm>

View File

@ -29,6 +29,8 @@
#include <macros.h> #include <macros.h>
#include <connectivity/connectivity_items.h> #include <connectivity/connectivity_items.h>
#include <wx/log.h>
int CN_ITEM::AnchorCount() const int CN_ITEM::AnchorCount() const
{ {
if( !m_valid ) if( !m_valid )

View File

@ -28,6 +28,7 @@
#include <wx/config.h> #include <wx/config.h>
#include <base_units.h> #include <base_units.h>
#include <widgets/ui_common.h> #include <widgets/ui_common.h>
#include <wx/log.h>
///! Update the schema version whenever a migration is required ///! Update the schema version whenever a migration is required

View File

@ -22,6 +22,7 @@
#include <kicad_string.h> #include <kicad_string.h>
#include <footprint.h> #include <footprint.h>
#include <fp_lib_table.h> #include <fp_lib_table.h>
#include <wx/log.h>
static const wxString DescriptionFormat = static const wxString DescriptionFormat =

View File

@ -23,6 +23,7 @@
*/ */
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
#include <wx/log.h>
#include <build_version.h> #include <build_version.h>
#include <board.h> #include <board.h>

View File

@ -28,6 +28,7 @@
#include <track.h> #include <track.h>
#include <zone.h> #include <zone.h>
#include <netinfo.h> #include <netinfo.h>
#include <wx/log.h>
// Constructor and destructor // Constructor and destructor

View File

@ -28,6 +28,7 @@
#include <track.h> #include <track.h>
#include <geometry/shape_segment.h> #include <geometry/shape_segment.h>
#include <pcb_expr_evaluator.h> #include <pcb_expr_evaluator.h>
#include <wx/log.h>
#include <connectivity/connectivity_data.h> #include <connectivity/connectivity_data.h>
#include <connectivity/connectivity_algo.h> #include <connectivity/connectivity_algo.h>

View File

@ -27,6 +27,8 @@
#include <ki_exception.h> #include <ki_exception.h>
#include <math/util.h> #include <math/util.h>
#include <wx/log.h>
#include "altium_parser_pcb.h" #include "altium_parser_pcb.h"
#include "plugins/altium/altium_parser.h" #include "plugins/altium/altium_parser.h"

View File

@ -44,6 +44,7 @@
#include <trigo.h> #include <trigo.h>
#include <utf.h> #include <utf.h>
#include <wx/docview.h> #include <wx/docview.h>
#include <wx/log.h>
#include <wx/mstream.h> #include <wx/mstream.h>
#include <wx/wfstream.h> #include <wx/wfstream.h>
#include <wx/zstream.h> #include <wx/zstream.h>

View File

@ -55,6 +55,7 @@ Load() TODO's
#include <wx/string.h> #include <wx/string.h>
#include <wx/xml/xml.h> #include <wx/xml/xml.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/log.h>
#include <wx/wfstream.h> #include <wx/wfstream.h>
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>

View File

@ -42,6 +42,7 @@
#include <wx_filename.h> #include <wx_filename.h>
#include <wx/dir.h> #include <wx/dir.h>
#include <wx/log.h>
#include <wx/filename.h> #include <wx/filename.h>
#include <wx/wfstream.h> #include <wx/wfstream.h>
#include <boost/ptr_container/ptr_map.hpp> #include <boost/ptr_container/ptr_map.hpp>

View File

@ -46,6 +46,7 @@
#include <track.h> #include <track.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <wx/dir.h> #include <wx/dir.h>
#include <wx/log.h>
#include <wx_filename.h> #include <wx_filename.h>
#include <zone.h> #include <zone.h>
#include <zones.h> #include <zones.h>

View File

@ -54,6 +54,7 @@
#include <plugins/kicad/pcb_parser.h> #include <plugins/kicad/pcb_parser.h>
#include <convert_basic_shapes_to_polygon.h> // for RECT_CHAMFER_POSITIONS definition #include <convert_basic_shapes_to_polygon.h> // for RECT_CHAMFER_POSITIONS definition
#include <template_fieldnames.h> #include <template_fieldnames.h>
#include <wx/log.h>
using namespace PCB_KEYS_T; using namespace PCB_KEYS_T;

View File

@ -42,6 +42,8 @@
#include <drc/drc_rule.h> #include <drc/drc_rule.h>
#include <drc/drc_engine.h> #include <drc/drc_engine.h>
#include <wx/log.h>
#include <memory> #include <memory>
#include <advanced_config.h> #include <advanced_config.h>

View File

@ -33,6 +33,8 @@
#include "pns_walkaround.h" #include "pns_walkaround.h"
#include "pns_mouse_trail_tracer.h" #include "pns_mouse_trail_tracer.h"
#include <wx/log.h>
namespace PNS { namespace PNS {
LINE_PLACER::LINE_PLACER( ROUTER* aRouter ) : LINE_PLACER::LINE_PLACER( ROUTER* aRouter ) :

View File

@ -23,6 +23,8 @@
#include "pns_item.h" #include "pns_item.h"
#include "pns_via.h" #include "pns_via.h"
#include <wx/log.h>
namespace PNS { namespace PNS {
LOGGER::LOGGER( ) LOGGER::LOGGER( )

View File

@ -29,6 +29,8 @@
#include <geometry/seg.h> #include <geometry/seg.h>
#include <geometry/shape_line_chain.h> #include <geometry/shape_line_chain.h>
#include <wx/log.h>
#include "pns_arc.h" #include "pns_arc.h"
#include "pns_item.h" #include "pns_item.h"
#include "pns_line.h" #include "pns_line.h"

View File

@ -25,6 +25,8 @@
#include <geometry/shape_compound.h> #include <geometry/shape_compound.h>
#include <wx/log.h>
#include "pns_arc.h" #include "pns_arc.h"
#include "pns_line.h" #include "pns_line.h"
#include "pns_node.h" #include "pns_node.h"

View File

@ -28,6 +28,8 @@
#include <geometry/shape_simple.h> #include <geometry/shape_simple.h>
#include <geometry/shape_compound.h> #include <geometry/shape_compound.h>
#include <wx/log.h>
#include "pns_router.h" #include "pns_router.h"
#include "pns_solid.h" #include "pns_solid.h"
#include "pns_utils.h" #include "pns_utils.h"