Don't use wxLogMessage/wxLogError for messages not meant for user.

They are particularly damaging when our event loop
gets tied up in knots with the log message window
behind a modal window -- thereby locking up KiCad.
This commit is contained in:
Jeff Young 2024-06-24 17:07:33 +01:00
parent 11c6164934
commit 26b86b3922
8 changed files with 29 additions and 47 deletions

View File

@ -71,7 +71,7 @@
#include <widgets/search_pane.h>
#include <wx/dirdlg.h>
#include <wx/filedlg.h>
#include <wx/msgdlg.h>
#include <wx/debug.h>
#include <wx/socket.h>
#include <wx/snglinst.h>
@ -1015,10 +1015,10 @@ void EDA_DRAW_FRAME::FocusOnLocation( const VECTOR2I& aPos )
{
GetCanvas()->GetView()->SetCenter( aPos, dialogScreenRects );
}
catch( const ClipperLib::clipperException& exc )
catch( const ClipperLib::clipperException& e )
{
wxLogError( wxT( "Clipper library error '%s' occurred centering object." ),
exc.what() );
wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred centering object: %s" ),
e.what() ) );
}
}

View File

@ -610,11 +610,7 @@ bool SCH_EDIT_FRAME::AppendSchematic()
{
SCH_SCREEN* screen = GetScreen();
if( !screen )
{
wxLogError( wxS( "Document not ready, cannot import" ) );
return false;
}
wxCHECK( screen, false );
// open file chooser dialog
wxString path = wxPathOnly( Prj().GetProjectFullName() );

View File

@ -40,7 +40,6 @@
#include <geometry/shape_segment.h>
#include <gestfich.h>
#include <dialogs/html_message_box.h>
#include <core/ignore.h>
#include <invoke_sch_dialog.h>
#include <string_utils.h>
#include <kiface_base.h>
@ -56,10 +55,8 @@
#include <sch_edit_frame.h>
#include <symbol_chooser_frame.h>
#include <sch_painter.h>
#include <sch_sheet.h>
#include <sch_marker.h>
#include <sch_sheet_pin.h>
#include <schematic.h>
#include <sch_commit.h>
#include <sch_rule_area.h>
#include <settings/settings_manager.h>
@ -78,7 +75,6 @@
#include <tools/ee_actions.h>
#include <tools/ee_inspection_tool.h>
#include <tools/ee_point_editor.h>
#include <tools/ee_selection_tool.h>
#include <tools/sch_drawing_tools.h>
#include <tools/sch_edit_tool.h>
#include <tools/sch_edit_table_tool.h>
@ -99,6 +95,7 @@
#include <wx/app.h>
#include <wx/filedlg.h>
#include <wx/socket.h>
#include <wx/debug.h>
#include <widgets/panel_sch_selection_filter.h>
#include <widgets/wx_aui_utils.h>
#include <drawing_sheet/ds_proxy_view_item.h>
@ -457,11 +454,9 @@ SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
{
GetSettingsManager()->UnloadProject( &Prj(), false );
}
catch( const nlohmann::detail::type_error& exc )
catch( const nlohmann::detail::type_error& e )
{
// This may be overkill and could be an assertion but we are more likely to
// find any settings manager errors this way.
wxLogError( wxT( "Settings exception '%s' occurred." ), exc.what() );
wxFAIL_MSG( wxString::Format( wxT( "Settings exception occurred: %s" ), e.what() ) );
}
}

View File

@ -1868,11 +1868,9 @@ BOX2I SCH_SYMBOL::GetBodyBoundingBox() const
{
return doGetBoundingBox( false, false );
}
catch( const boost::bad_pointer& exc )
catch( const boost::bad_pointer& e )
{
// This may be overkill and could be an assertion but we are more likely to
// find any boost pointer container errors this way.
wxLogError( wxT( "Boost bad pointer exception '%s' occurred." ), exc.what() );
wxFAIL_MSG( wxString::Format( wxT( "Boost pointer exception occurred: %s" ), e.what() ) );
return BOX2I();
}
}

View File

@ -30,7 +30,7 @@
#include <gal/graphics_abstraction_layer.h>
#include <sch_shape.h>
#include <sch_commit.h>
#include <wx/log.h>
#include <wx/debug.h>
#include <view/view_controls.h>
#include "symbol_editor_move_tool.h"
#include "symbol_editor_pin_tool.h"
@ -343,7 +343,8 @@ bool SYMBOL_EDITOR_MOVE_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, SCH_COM
catch( const boost::bad_pointer& e )
{
restore_state = true;
wxLogError( "Boost pointer exception occurred: \"%s\"", e.what() );
wxFAIL_MSG( wxString::Format( wxT( "Boost pointer exception occurred: %s" ),
e.what() ) );
}
}

View File

@ -31,7 +31,7 @@
#include <settings/settings_manager.h>
#include <symbol_editor/symbol_editor_settings.h>
#include <pgm_base.h>
#include <wx/log.h>
#include <wx/debug.h>
#include "symbol_editor_pin_tool.h"
@ -357,8 +357,8 @@ void SYMBOL_EDITOR_PIN_TOOL::CreateImagePins( SCH_PIN* aPin )
}
catch( const boost::bad_pointer& e )
{
wxLogError( "Cannot add new pin to symbol. Boost pointer error %s occurred.",
e.what() );
wxFAIL_MSG( wxString::Format( wxT( "Boost pointer exception occurred: %s" ),
e.what() ));
delete newPin;
return;
}

View File

@ -321,11 +321,9 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
{
viewportPoly.BooleanSubtract( dialogPoly, SHAPE_POLY_SET::PM_FAST );
}
catch( const std::exception& exc )
catch( const std::exception& e )
{
// This may be overkill and could be an assertion but we are more likely to
// find any clipper errors this way.
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ), e.what() ) );
}
}
@ -361,11 +359,10 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
{
itemPoly = static_cast<FOOTPRINT*>( item )->GetBoundingHull();
}
catch( const std::exception& exc )
catch( const std::exception& e )
{
// This may be overkill and could be an assertion but we are more likely to
// find any clipper errors this way.
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ),
e.what() ) );
}
break;
@ -430,11 +427,9 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
{
clippedPoly.BooleanIntersection( itemPoly, viewportPoly, SHAPE_POLY_SET::PM_FAST );
}
catch( const std::exception& exc )
catch( const std::exception& e )
{
// This may be overkill and could be an assertion but we are more likely to
// find any clipper errors this way.
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ), e.what() ) );
}
if( !clippedPoly.IsEmpty() )
@ -457,11 +452,9 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
{
itemPoly.Deflate( step, CORNER_STRATEGY::ALLOW_ACUTE_CORNERS, ARC_LOW_DEF );
}
catch( const std::exception& exc )
catch( const std::exception& e )
{
// This may be overkill and could be an assertion but we are more likely to
// find any clipper errors this way.
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ), e.what() ) );
}
}

View File

@ -72,6 +72,7 @@ using namespace std::placeholders;
#include <wx/event.h>
#include <wx/timer.h>
#include <wx/log.h>
#include <wx/debug.h>
#include <core/profile.h>
#include <math/vector2wx.h>
@ -3251,11 +3252,9 @@ int PCB_SELECTION_TOOL::hitTestDistance( const VECTOR2I& aWhere, BOARD_ITEM* aIt
{
footprint->GetBoundingHull().Collide( loc, aMaxDistance, &distance );
}
catch( const std::exception& exc )
catch( const std::exception& e )
{
// This may be overkill and could be an assertion but we are more likely to find
// any clipper errors this way.
wxLogError( wxT( "Clipper library exception '%s' occurred." ), exc.what() );
wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ), e.what() ) );
}
// Consider footprints larger than the viewport only as a last resort
@ -3580,7 +3579,7 @@ void PCB_SELECTION_TOOL::GuessSelectionCandidates( GENERAL_COLLECTOR& aCollector
}
catch( const std::exception& e )
{
wxLogError( wxT( "A clipper exception %s was detected." ), e.what() );
wxFAIL_MSG( wxString::Format( wxT( "Clipper exception occurred: %s" ), e.what() ) );
}
}