Debugging improvements and clean up.
* Remove unused wxLogDebug calls. * Add add application level character tracing to detect unhandled key events. * Catch unhandled exceptions in KiCad main event loop like single top applications.
This commit is contained in:
parent
939b5e1932
commit
d2a7f81b10
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* 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 );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2020 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* 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<OBJECT_2D_TYPE, const char*> 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<int>( objectType.first )] );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* 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<int>( aObjType )]++;
|
||||
}
|
||||
|
||||
void PrintStats();
|
||||
|
||||
static OBJECT_2D_STATS& Instance()
|
||||
{
|
||||
if( !s_instance )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2017 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* 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 );
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
||||
* 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.
|
||||
*
|
||||
|
|
|
@ -64,13 +64,13 @@ const std::map<OBJECT_3D_TYPE, const char*> 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<int>( objectType.first )] );
|
||||
}
|
||||
}
|
||||
// for( auto& objectType : objectTypeNames )
|
||||
// {
|
||||
// wxLogDebug( " %20s %u\n", objectType.second,
|
||||
// m_counter[static_cast<int>( objectType.first )] );
|
||||
// }
|
||||
// }
|
||||
|
|
|
@ -127,7 +127,7 @@ public:
|
|||
m_counter[static_cast<int>( aObjType )]++;
|
||||
}
|
||||
|
||||
void PrintStats();
|
||||
// void PrintStats();
|
||||
|
||||
static OBJECT_3D_STATS& Instance()
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -506,6 +506,8 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
|||
{
|
||||
wxKeyEvent* ke = static_cast<wxKeyEvent*>( &aEvent );
|
||||
|
||||
wxLogTrace( kicadTraceKeyEvent, "TOOL_DISPATCHER::DispatchWxEvent %s", dump( *ke ) );
|
||||
|
||||
keyIsEscape = ( ke->GetKeyCode() == WXK_ESCAPE );
|
||||
|
||||
wxTextEntry* textEntry = dynamic_cast<wxTextEntry*>( focus );
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -234,7 +234,6 @@ static std::mutex s_symbolTableMutex;
|
|||
|
||||
SYMBOL_LIB_TABLE* PROJECT::SchSymbolLibTable()
|
||||
{
|
||||
wxLogDebug( "Getting symbol lib table" );
|
||||
std::lock_guard<std::mutex> lock( s_symbolTableMutex );
|
||||
|
||||
// This is a lazy loading function, it loads the project specific table when
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -39,8 +39,10 @@
|
|||
#include <kiway.h>
|
||||
#include <macros.h>
|
||||
#include <paths.h>
|
||||
#include <richio.h>
|
||||
#include <settings/settings_manager.h>
|
||||
#include <systemdirsappend.h>
|
||||
#include <trace_helpers.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
@ -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<wxKeyEvent*>( &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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue