diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp index 9faf6e0d3d..2f673fbf7a 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/ray.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2017 Mario Luzeiro - * Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2015-2021 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 @@ -364,10 +364,3 @@ bool RAYSEG2D::IntersectCircle( const SFVEC2F &aCenter, float aRadius, float *aO return true; } - - -void RAY::debug() const -{ - wxLogDebug( "O(%f, %f, %f) D(%f, %f, %f)\n", m_Origin.x, m_Origin.y, m_Origin.z, - m_Dir.x, m_Dir.y, m_Dir.z ); -} diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/ray.h b/3d-viewer/3d_rendering/3d_render_raytracing/ray.h index 4df3ec85cc..5ff48fccf5 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/ray.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/ray.h @@ -88,10 +88,10 @@ struct RAY SFVEC3F at( float t ) const { return m_Origin + m_Dir * t; } - SFVEC2F at2D( float t ) const { - return SFVEC2F( m_Origin.x + m_Dir.x * t, m_Origin.y + m_Dir.y * t ); } - - void debug() const; + SFVEC2F at2D( float t ) const + { + return SFVEC2F( m_Origin.x + m_Dir.x * t, m_Origin.y + m_Dir.y * t ); + } }; diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/object_2d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/object_2d.cpp index 245eba3fda..cfeaadac96 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/object_2d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/object_2d.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2020 Mario Luzeiro - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 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 @@ -59,13 +59,3 @@ const std::map objectTypeNames { OBJECT_2D_TYPE::BVHCONTAINER, "OBJECT_2D_TYPE::BVHCONTAINER" }, }; // clang-format on - - -void OBJECT_2D_STATS::PrintStats() -{ - for( auto& objectType : objectTypeNames ) - { - wxLogDebug( " %20s %u\n", objectType.second, - m_counter[static_cast( objectType.first )] ); - } -} diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/object_2d.h b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/object_2d.h index a83b652201..797852a666 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/object_2d.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes2D/object_2d.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Mario Luzeiro - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 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 @@ -134,8 +134,6 @@ public: m_counter[static_cast( aObjType )]++; } - void PrintStats(); - static OBJECT_2D_STATS& Instance() { if( !s_instance ) diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/bbox_3d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/bbox_3d.cpp index 5fd0e59c7c..8f59649458 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/bbox_3d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/bbox_3d.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2017 Mario Luzeiro - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 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 @@ -377,10 +377,3 @@ void BBOX_3D::ApplyTransformationAA( glm::mat4 aTransformMatrix ) m_min = tmpBBox.m_min; m_max = tmpBBox.m_max; } - - -void BBOX_3D::debug() const -{ - wxLogDebug( "min(%f, %f, %f) - max(%f, %f, %f)\n", m_min.x, m_min.y, m_min.z, - m_max.x, m_max.y, m_max.z ); -} diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/bbox_3d.h b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/bbox_3d.h index 4e5d07f4b8..0484946799 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/bbox_3d.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/bbox_3d.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015-2016 Mario Luzeiro - * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2021 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 @@ -147,11 +147,6 @@ public: */ float Volume() const; - /** - * Output this BBOX_3D to the stdout. - */ - void debug() const; - /** * Check if this bounding box is already initialized. * diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/object_3d.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/object_3d.cpp index 8871775c60..3496cb5ddd 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/object_3d.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/object_3d.cpp @@ -64,13 +64,13 @@ const std::map objectTypeNames // clang-format on -void OBJECT_3D_STATS::PrintStats() -{ - wxLogDebug( "OBJECT_3D_STATS:\n" ); +// void OBJECT_3D_STATS::PrintStats() +// { +// wxLogDebug( "OBJECT_3D_STATS:\n" ); - for( auto& objectType : objectTypeNames ) - { - wxLogDebug( " %20s %u\n", objectType.second, - m_counter[static_cast( objectType.first )] ); - } -} +// for( auto& objectType : objectTypeNames ) +// { +// wxLogDebug( " %20s %u\n", objectType.second, +// m_counter[static_cast( objectType.first )] ); +// } +// } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/object_3d.h b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/object_3d.h index 07a61e107b..a27baaf9df 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/object_3d.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/shapes3D/object_3d.h @@ -127,7 +127,7 @@ public: m_counter[static_cast( aObjType )]++; } - void PrintStats(); + // void PrintStats(); static OBJECT_3D_STATS& Instance() { diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 754c185d1e..76464e2762 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -304,12 +304,13 @@ bool EDA_BASE_FRAME::doAutoSave() } -void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& event ) +void EDA_BASE_FRAME::OnCharHook( wxKeyEvent& aKeyEvent ) { - wxLogTrace( kicadTraceKeyEvent, "EDA_BASE_FRAME::OnCharHook %s", dump( event ) ); + wxLogTrace( kicadTraceKeyEvent, "EDA_BASE_FRAME::OnCharHook %s", dump( aKeyEvent ) ); + // Key events can be filtered here. // Currently no filtering is made. - event.Skip(); + aKeyEvent.Skip(); } diff --git a/common/tool/tool_dispatcher.cpp b/common/tool/tool_dispatcher.cpp index d4fe201da0..5b3620bfd2 100644 --- a/common/tool/tool_dispatcher.cpp +++ b/common/tool/tool_dispatcher.cpp @@ -506,6 +506,8 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) { wxKeyEvent* ke = static_cast( &aEvent ); + wxLogTrace( kicadTraceKeyEvent, "TOOL_DISPATCHER::DispatchWxEvent %s", dump( *ke ) ); + keyIsEscape = ( ke->GetKeyCode() == WXK_ESCAPE ); wxTextEntry* textEntry = dynamic_cast( focus ); diff --git a/common/trace_helpers.cpp b/common/trace_helpers.cpp index f39d23effd..4e054b678a 100644 --- a/common/trace_helpers.cpp +++ b/common/trace_helpers.cpp @@ -253,8 +253,7 @@ wxString dump( const wxKeyEvent& aEvent ) #else " not-set not-set" #endif - " (%5d,%5d)" - "\n", + " (%5d,%5d)", eventType, GetKeyName( aEvent ), aEvent.GetKeyCode(), diff --git a/eeschema/eeschema_config.cpp b/eeschema/eeschema_config.cpp index 6f307e88d2..ccac53bf54 100644 --- a/eeschema/eeschema_config.cpp +++ b/eeschema/eeschema_config.cpp @@ -234,7 +234,6 @@ static std::mutex s_symbolTableMutex; SYMBOL_LIB_TABLE* PROJECT::SchSymbolLibTable() { - wxLogDebug( "Getting symbol lib table" ); std::lock_guard lock( s_symbolTableMutex ); // This is a lazy loading function, it loads the project specific table when diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index 7a74d4d8c9..896b3e739e 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -144,7 +144,7 @@ public: * function to capture and filter these keys when they are used as hotkeys, and skip it if * the key is not used as hotkey (otherwise the key events will be not sent to menus). */ - virtual void OnCharHook( wxKeyEvent& event ); + virtual void OnCharHook( wxKeyEvent& aKeyEvent ); /** * The #TOOL_DISPATCHER needs these to work around some issues in wxWidgets where the menu diff --git a/kicad/kicad.cpp b/kicad/kicad.cpp index 6090e9300d..0dc38530e1 100644 --- a/kicad/kicad.cpp +++ b/kicad/kicad.cpp @@ -39,8 +39,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -328,6 +330,56 @@ struct APP_KICAD : public wxApp return Event_Skip; } +#if defined( DEBUG ) + /** + * Process any unhandled events at the application level. + */ + bool ProcessEvent( wxEvent& aEvent ) override + { + if( aEvent.GetEventType() == wxEVT_CHAR || aEvent.GetEventType() == wxEVT_CHAR_HOOK ) + { + wxKeyEvent* keyEvent = static_cast( &aEvent ); + + if( keyEvent ) + wxLogTrace( kicadTraceKeyEvent, "APP_KICAD::ProcessEvent %s", dump( *keyEvent ) ); + } + + aEvent.Skip(); + return false; + } + + /** + * Override main loop exception handling on debug builds. + * + * It can be painfully difficult to debug exceptions that happen in wxUpdateUIEvent + * handlers. The override provides a bit more useful information about the exception + * and a breakpoint can be set to pin point the event where the exception was thrown. + */ + bool OnExceptionInMainLoop() override + { + try + { + throw; + } + catch( const std::exception& e ) + { + wxLogError( "Unhandled exception class: %s what: %s", + FROM_UTF8( typeid(e).name() ), + FROM_UTF8( e.what() ) ); + } + catch( const IO_ERROR& ioe ) + { + wxLogError( ioe.What() ); + } + catch(...) + { + wxLogError( "Unhandled exception of unknown type" ); + } + + return false; // continue on. Return false to abort program + } +#endif + /** * Set MacOS file associations. *