From bf80b9c04cb99f63f33be87839258e7253cb98fc Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Tue, 20 Jul 2021 10:32:22 -0400 Subject: [PATCH] Last of the NULL expunging. --- libs/kiplatform/gtk/environment.cpp | 4 +- libs/kiplatform/osx/environment.mm | 9 ++-- qa/eeschema/mocks_eeschema.cpp | 19 ++++--- qa/eeschema/test_lib_part.cpp | 2 +- qa/pns/pns_log_viewer.cpp | 83 ++++++++++++++++++----------- qa/qa_utils/pcb_test_frame.cpp | 23 ++++---- qa/qa_utils/test_app_main.cpp | 51 +++++++++--------- 7 files changed, 110 insertions(+), 81 deletions(-) diff --git a/libs/kiplatform/gtk/environment.cpp b/libs/kiplatform/gtk/environment.cpp index 10476a66d6..1fe88a6626 100644 --- a/libs/kiplatform/gtk/environment.cpp +++ b/libs/kiplatform/gtk/environment.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Ian McInerney - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-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 as published by the @@ -55,7 +55,7 @@ bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) GError* err = nullptr; GFile* file = g_file_new_for_path( aPath.fn_str() ); - bool retVal = g_file_trash( file, NULL, &err ); + bool retVal = g_file_trash( file, nullptr, &err ); // Extract the error string if the operation failed if( !retVal && err ) diff --git a/libs/kiplatform/osx/environment.mm b/libs/kiplatform/osx/environment.mm index 4a3bc77986..f85c157212 100644 --- a/libs/kiplatform/osx/environment.mm +++ b/libs/kiplatform/osx/environment.mm @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2020 Ian McInerney - * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2020-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 as published by the @@ -39,7 +39,7 @@ bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) { bool isDirectory = wxDirExists( aPath ); NSURL* url = [NSURL fileURLWithPath:wxCFStringRef( aPath ).AsNSString() isDirectory:isDirectory]; - NSError* err = NULL; + NSError* err = nullptr; BOOL result = [[NSFileManager defaultManager] trashItemAtURL:url resultingItemURL:nil error:&err]; @@ -54,7 +54,8 @@ bool KIPLATFORM::ENV::MoveToTrash( const wxString& aPath, wxString& aError ) } else { - errmsg = [err.localizedFailureReason stringByAppendingFormat:@"\n\n%@", err.localizedRecoverySuggestion]; + errmsg = [err.localizedFailureReason stringByAppendingFormat:@"\n\n%@", + err.localizedRecoverySuggestion]; } aError = wxCFStringRef::AsString( (CFStringRef) errmsg ); @@ -91,5 +92,5 @@ wxString KIPLATFORM::ENV::GetUserCachePath() appropriateForURL:nil create:NO error:nil]; - return wxCFStringRef::AsString((CFStringRef)url.path); + return wxCFStringRef::AsString( ( CFStringRef) url.path ); } diff --git a/qa/eeschema/mocks_eeschema.cpp b/qa/eeschema/mocks_eeschema.cpp index 1823192232..57916ca9cb 100644 --- a/qa/eeschema/mocks_eeschema.cpp +++ b/qa/eeschema/mocks_eeschema.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2019-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 @@ -34,6 +34,7 @@ // a transform matrix, to display components in lib editor TRANSFORM DefaultTransform = TRANSFORM( 1, 0, 0, -1 ); + static struct IFACE : public KIFACE_I { // Of course all are overloads, implementations of the KIFACE. @@ -59,22 +60,22 @@ static struct IFACE : public KIFACE_I } /** - * Function IfaceOrAddress - * return a pointer to the requested object. The safest way to use this - * is to retrieve a pointer to a static instance of an interface, similar to - * how the KIFACE interface is exported. But if you know what you are doing + * Return a pointer to the requested object. + * + * The safest way to use this is to retrieve a pointer to a static instance of an interface, + * similar to how the KIFACE interface is exported. But if you know what you are doing * use it to retrieve anything you want. * * @param aDataId identifies which object you want the address of. - * - * @return void* - and must be cast into the know type. + * @return requested object which must be cast into the know type. */ void* IfaceOrAddress( int aDataId ) override { - return NULL; + return nullptr; } } kiface( "mock_eeschema", KIWAY::FACE_SCH ); + static struct PGM_MOCK_EESCHEMA_FRAME : public PGM_BASE { bool OnPgmInit(); @@ -108,11 +109,13 @@ static struct PGM_MOCK_EESCHEMA_FRAME : public PGM_BASE } } program; + PGM_BASE& Pgm() { return program; } + // Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from // a python script or something else. // Therefore here return always nullptr diff --git a/qa/eeschema/test_lib_part.cpp b/qa/eeschema/test_lib_part.cpp index a1a9b6d0de..aa337c453b 100644 --- a/qa/eeschema/test_lib_part.cpp +++ b/qa/eeschema/test_lib_part.cpp @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE( DefaultDrawings ) { // default drawings exist BOOST_CHECK_EQUAL( m_part_no_data.GetDrawItems().size(), 4 ); - BOOST_CHECK_EQUAL( m_part_no_data.GetNextDrawItem( NULL, LIB_PIN_T ), (LIB_ITEM*)NULL ); + BOOST_CHECK_EQUAL( m_part_no_data.GetNextDrawItem( nullptr, LIB_PIN_T ), nullptr ); } diff --git a/qa/pns/pns_log_viewer.cpp b/qa/pns/pns_log_viewer.cpp index 74f3595d78..b9b976ae8f 100644 --- a/qa/pns/pns_log_viewer.cpp +++ b/qa/pns/pns_log_viewer.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020 KiCad Developers. + * Copyright (C) 2020-2021 KiCad Developers. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -50,6 +50,7 @@ LABEL_MANAGER::LABEL_MANAGER( KIGFX::GAL* aGal ) : m_gal( aGal ) }; + LABEL_MANAGER::~LABEL_MANAGER() { } @@ -71,6 +72,7 @@ void LABEL_MANAGER::Add( VECTOR2I target, std::string msg, COLOR4D color ) m_labels.push_back( lbl ); } + void LABEL_MANAGER::Add( const SHAPE_LINE_CHAIN& aL, COLOR4D color ) { for( int i = 0; i < aL.PointCount(); i++ ) @@ -84,9 +86,9 @@ void LABEL_MANAGER::Add( const SHAPE_LINE_CHAIN& aL, COLOR4D color ) void LABEL_MANAGER::Redraw( KIGFX::VIEW_OVERLAY* aOvl ) { recalculate(); + for( auto& lbl : m_labels ) { - //printf("Draw lbl %d %d '%s'\n", lbl.m_bbox.GetOrigin().x, lbl.m_bbox.GetOrigin().y, lbl.m_msg.c_str() ); aOvl->SetIsFill( false ); aOvl->SetIsStroke( true ); aOvl->SetLineWidth( 10000 ); @@ -111,6 +113,7 @@ VECTOR2I LABEL_MANAGER::nearestBoxCorner( BOX2I b, VECTOR2I p ) for( int i = 0; i < 4; i++ ) { int dist = ( ptest[i] - p ).EuclideanNorm(); + if( dist < bestDist ) { bestDist = dist; @@ -121,6 +124,7 @@ VECTOR2I LABEL_MANAGER::nearestBoxCorner( BOX2I b, VECTOR2I p ) return rv; } + VECTOR2I LABEL_MANAGER::boxMtv( BOX2I b1, BOX2I b2 ) { VECTOR2I rv( 0, 0 ); @@ -151,9 +155,11 @@ VECTOR2I LABEL_MANAGER::boxMtv( BOX2I b1, BOX2I b2 ) { BOX2I btest( b2 ); btest.Move( dp[j] ); + if( !b1.Intersects( btest ) ) { int dist = dp[j].EuclideanNorm(); + if( dist < bestDist ) { bestDist = dist; @@ -167,13 +173,16 @@ VECTOR2I LABEL_MANAGER::boxMtv( BOX2I b1, BOX2I b2 ) return rv; } + void LABEL_MANAGER::recalculate() { int iterLimit = 5; + while( iterLimit > 0 ) { printf( "Iter %d\n", iterLimit ); bool collisionsFound = false; + for( int i = 0; i < m_labels.size(); i++ ) { for( int j = 0; j < m_labels.size(); j++ ) @@ -181,7 +190,6 @@ void LABEL_MANAGER::recalculate() if( i == j ) continue; - auto bb_i = m_labels[i].m_bbox; auto bb_j = m_labels[j].m_bbox; @@ -189,11 +197,8 @@ void LABEL_MANAGER::recalculate() bb_j.Inflate( 100000 ); VECTOR2I mtv = boxMtv( bb_i, bb_j ); - if( mtv.x || mtv.y ) { - // printf("%d %d mtv %d %d\n", i, j, mtv.x, mtv.y ); - m_labels[i].m_bbox.Move( -mtv ); collisionsFound = true; } @@ -222,9 +227,12 @@ PNS_LOG_VIEWER_OVERLAY::PNS_LOG_VIEWER_OVERLAY( KIGFX::GAL* aGal ) m_labelMgr.reset( new LABEL_MANAGER( aGal ) ); } -void PNS_LOG_VIEWER_OVERLAY::AnnotatedPolyline( const SHAPE_LINE_CHAIN& aL, std::string name, bool aShowVertexNumbers ) + +void PNS_LOG_VIEWER_OVERLAY::AnnotatedPolyline( const SHAPE_LINE_CHAIN& aL, std::string name, + bool aShowVertexNumbers ) { Polyline( aL ); + if( aShowVertexNumbers) m_labelMgr->Add( aL, GetStrokeColor() ); } @@ -261,13 +269,15 @@ PNS_LOG_VIEWER_FRAME::PNS_LOG_VIEWER_FRAME( wxFrame* frame ) : PNS_LOG_VIEWER_FR m_listPopupMenu->Append( ID_LIST_SHOW_NONE, wxT( "Show none" ), wxT( "" ), wxITEM_NORMAL ); m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_ITEM_CONTEXT_MENU, - wxMouseEventHandler( PNS_LOG_VIEWER_FRAME::onListRightClick ), NULL, + wxMouseEventHandler( PNS_LOG_VIEWER_FRAME::onListRightClick ), nullptr, this ); - //m_itemList->Connect(m_itemList->GetId(),wxEVT_LISTBOX,wxCommandEventHandler(PNS_LOG_VIEWER_FRAME::onListSelect),NULL,this); + //m_itemList->Connect(m_itemList->GetId(),wxEVT_LISTBOX,wxCommandEventHandler(PNS_LOG_VIEWER_FRAME::onListSelect),nullptr,this); m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_SELECTION_CHANGED, - wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListSelect ), NULL, this ); + wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListSelect ), + nullptr, this ); m_itemList->Connect( m_itemList->GetId(), wxEVT_TREELIST_ITEM_CHECKED, - wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListChecked ), NULL, this ); + wxCommandEventHandler( PNS_LOG_VIEWER_FRAME::onListChecked ), + nullptr, this ); m_itemList->AppendColumn( "Type" ); m_itemList->AppendColumn( "Value" ); @@ -279,6 +289,7 @@ PNS_LOG_VIEWER_FRAME::PNS_LOG_VIEWER_FRAME( wxFrame* frame ) : PNS_LOG_VIEWER_FR m_galPanel->GetView()->Add( m_overlay.get() ); } + PNS_LOG_VIEWER_FRAME::~PNS_LOG_VIEWER_FRAME() { m_overlay = nullptr; @@ -310,6 +321,7 @@ PNS_TEST_DEBUG_DECORATOR::STAGE* PNS_LOG_VIEWER_FRAME::getCurrentStage() return dbgd->GetStage( iter ); } + void PNS_LOG_VIEWER_FRAME::drawLoggedItems( int iter ) { if( !m_env ) @@ -319,15 +331,15 @@ void PNS_LOG_VIEWER_FRAME::drawLoggedItems( int iter ) if( !st ) return; - + m_overlay.reset( new PNS_LOG_VIEWER_OVERLAY ( m_galPanel->GetGAL() ) ); m_galPanel->GetView()->Add( m_overlay.get() ); -// - printf("draw %d\n", iter); - auto drawShapes = [&]( PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT* ent ) -> bool { + auto drawShapes = [&]( PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT* ent ) -> bool + { bool isEnabled = ent->IsVisible(); bool isSelected = false; + if( !isEnabled ) return true; @@ -366,16 +378,16 @@ void PNS_LOG_VIEWER_FRAME::drawLoggedItems( int iter ) case SH_LINE_CHAIN: { auto lc = static_cast( sh ); - m_overlay->AnnotatedPolyline( *lc, ent->m_name, ent->m_hasLabels && isSelected ); + m_overlay->AnnotatedPolyline( *lc, ent->m_name, ent->m_hasLabels && isSelected ); break; } - default: break; + default: + break; } } - return true; }; @@ -395,11 +407,10 @@ static BOARD* loadBoard( const std::string& filename ) try { - brd = pi->Load( wxString( filename.c_str() ), NULL, NULL ); + brd = pi->Load( wxString( filename.c_str() ), nullptr, nullptr ); } catch( const IO_ERROR& ioe ) { - printf( "Board Loading Error: '%s'\n", ioe.Problem() ); return nullptr; } @@ -439,6 +450,7 @@ void PNS_LOG_VIEWER_FRAME::SetLogFile( PNS_LOG_FILE* aLog ) updateDumpPanel( m_rewindIter ); } + void PNS_LOG_VIEWER_FRAME::onReload( wxCommandEvent& event ) { event.Skip(); @@ -449,6 +461,7 @@ void PNS_LOG_VIEWER_FRAME::onExit( wxCommandEvent& event ) event.Skip(); } + void PNS_LOG_VIEWER_FRAME::onListChecked( wxCommandEvent& event ) { syncModel(); @@ -467,6 +480,7 @@ void PNS_LOG_VIEWER_FRAME::onRewindScroll( wxScrollEvent& event ) event.Skip(); } + void PNS_LOG_VIEWER_FRAME::onBtnRewindLeft( wxCommandEvent& event ) { if( m_rewindIter > 0 ) @@ -480,6 +494,7 @@ void PNS_LOG_VIEWER_FRAME::onBtnRewindLeft( wxCommandEvent& event ) } } + void PNS_LOG_VIEWER_FRAME::onBtnRewindRight( wxCommandEvent& event ) { auto dbgd = m_env->GetDebugDecorator(); @@ -496,6 +511,7 @@ void PNS_LOG_VIEWER_FRAME::onBtnRewindRight( wxCommandEvent& event ) } } + void PNS_LOG_VIEWER_FRAME::onRewindCountText( wxCommandEvent& event ) { if( !m_env ) @@ -520,6 +536,7 @@ void PNS_LOG_VIEWER_FRAME::onRewindCountText( wxCommandEvent& event ) event.Skip(); } + void PNS_LOG_VIEWER_FRAME::syncModel() { for( wxTreeListItem item = m_itemList->GetFirstItem(); item.IsOk(); @@ -527,6 +544,7 @@ void PNS_LOG_VIEWER_FRAME::syncModel() { WX_SHAPE_TREE_ITEM_DATA* idata = static_cast( m_itemList->GetItemData( item ) ); + if( idata ) { bool checked = m_itemList->GetCheckedState( item ) == wxCHK_CHECKED; @@ -535,9 +553,9 @@ void PNS_LOG_VIEWER_FRAME::syncModel() idata->m_item->m_selected = selected; } } - } + void PNS_LOG_VIEWER_FRAME::onListRightClick( wxMouseEvent& event ) { auto sel = m_itemList->GetPopupMenuSelectionFromUser( *m_listPopupMenu ); @@ -563,17 +581,16 @@ void PNS_LOG_VIEWER_FRAME::onListRightClick( wxMouseEvent& event ) if( !st ) return; - auto formatShapes = [&]( PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT* ent ) -> bool { + auto formatShapes = [&]( PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT* ent ) -> bool + { if( ent->m_selected ) { - //printf("Ent %p\n", ent ); for( auto sh : ent->m_shapes ) { - //printf("sh %p\n", sh ); - //printf("%s\n", sh->Format().c_str() ); s += "// " + ent->m_name + "\n " + sh->Format() + "; \n"; } } + return true; }; @@ -587,11 +604,13 @@ void PNS_LOG_VIEWER_FRAME::onListRightClick( wxMouseEvent& event ) wxTheClipboard->Flush(); // Allow data to be available after closing KiCad wxTheClipboard->Close(); } + return; } } } + void PNS_LOG_VIEWER_FRAME::onListSelect( wxCommandEvent& event ) { syncModel(); @@ -599,7 +618,7 @@ void PNS_LOG_VIEWER_FRAME::onListSelect( wxCommandEvent& event ) } -void PNS_LOG_VIEWER_FRAME::buildListTree( wxTreeListItem item, +void PNS_LOG_VIEWER_FRAME::buildListTree( wxTreeListItem item, PNS_TEST_DEBUG_DECORATOR::DEBUG_ENT* ent, int depth ) { #ifdef EXTRA_VERBOSE @@ -648,13 +667,15 @@ void PNS_LOG_VIEWER_FRAME::buildListTree( wxTreeListItem i static void expandAllChildren( wxTreeListCtrl* tree ) { wxTreeListItem child = tree->GetFirstItem (); - while (child.IsOk()) + + while( child.IsOk() ) { tree->Expand ( child ); child = tree->GetNextItem( child ); } } + void PNS_LOG_VIEWER_FRAME::updateDumpPanel( int iter ) { if( !m_env ) @@ -674,7 +695,6 @@ void PNS_LOG_VIEWER_FRAME::updateDumpPanel( int iter ) if( iter >= count ) iter = count - 1; - auto st = dbgd->GetStage( iter ); auto rootItem = m_itemList->GetRootItem(); @@ -693,13 +713,12 @@ int replay_main_func( int argc, char* argv[] ) auto frame = new PNS_LOG_VIEWER_FRAME( nullptr ); // drcCreateTestsProviderClearance(); - // drcCreateTestsProviderEdgeClearance(); - + // drcCreateTestsProviderEdgeClearance(); if( argc >= 2 && std::string( argv[1] ) == "-h" ) { printf( "PNS Log (Re)player. Allows to step through the log written by the ROUTER_TOOL " - "in debug Kicad builds. " ); + "in debug KiCad builds. " ); printf( "Requires a board file with UUIDs and a matching log file. Both are written to " "/tmp when you press '0' during routing." ); return 0; @@ -720,9 +739,9 @@ int replay_main_func( int argc, char* argv[] ) return 0; } + static bool registered2 = UTILITY_REGISTRY::Register( { "replay", "PNS Log Player", replay_main_func, } ); - diff --git a/qa/qa_utils/pcb_test_frame.cpp b/qa/qa_utils/pcb_test_frame.cpp index 7d1e7786c6..7c14e27364 100644 --- a/qa/qa_utils/pcb_test_frame.cpp +++ b/qa/qa_utils/pcb_test_frame.cpp @@ -2,6 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013-2017 CERN + * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * * This program is free software; you can redistribute it and/or @@ -68,9 +69,9 @@ #include "pcb_test_frame.h" - using namespace KIGFX; + void PCB_TEST_FRAME_BASE::SetBoard( std::shared_ptr b ) { m_board = b; @@ -80,9 +81,8 @@ void PCB_TEST_FRAME_BASE::SetBoard( std::shared_ptr b ) m_galPanel->UpdateColors(); #ifdef USE_TOOL_MANAGER - m_toolManager->SetEnvironment( m_board.get(), m_galPanel->GetView(), - m_galPanel->GetViewControls(), nullptr ); + m_galPanel->GetViewControls(), nullptr ); m_toolManager->ResetTools( TOOL_BASE::MODEL_RELOAD ); #endif @@ -96,7 +96,7 @@ BOARD* PCB_TEST_FRAME_BASE::LoadAndDisplayBoard( const std::string& filename ) try { - brd = pi->Load( wxString( filename.c_str() ), NULL, NULL ); + brd = pi->Load( wxString( filename.c_str() ), nullptr, nullptr ); } catch( const IO_ERROR& ioe ) { @@ -109,16 +109,19 @@ BOARD* PCB_TEST_FRAME_BASE::LoadAndDisplayBoard( const std::string& filename ) return brd; } + class TEST_ACTIONS : public ACTIONS { }; + void PCB_TEST_FRAME_BASE::createView( wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL_TYPE aGalType ) { - m_displayOptions.gl_antialiasing_mode = KIGFX::OPENGL_ANTIALIASING_MODE::NONE; //SUPERSAMPLING_X4; + // SUPERSAMPLING_X4; + m_displayOptions.gl_antialiasing_mode = KIGFX::OPENGL_ANTIALIASING_MODE::NONE; - m_galPanel = std::make_shared( aParent, -1, wxPoint( 0, - 0 ), wxDefaultSize, m_displayOptions, aGalType ); + m_galPanel = std::make_shared( aParent, -1, wxPoint( 0, 0 ), + wxDefaultSize, m_displayOptions, aGalType ); m_galPanel->UpdateColors(); m_galPanel->SetEvtHandlerEnabled( true ); @@ -134,14 +137,14 @@ void PCB_TEST_FRAME_BASE::createView( wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL gal->SetGridOrigin( VECTOR2D( 0.0, 0.0 ) ); //m_galPanel->Connect( wxEVT_MOTION, - //wxMouseEventHandler( PCB_TEST_FRAME::OnMotion ), NULL, this ); + //wxMouseEventHandler( PCB_TEST_FRAME::OnMotion ), nullptr, this ); m_galPanel->GetViewControls()->ShowCursor( true ); #ifdef USE_TOOL_MANAGER m_toolManager = std::make_unique( ); m_toolManager->SetEnvironment( m_board.get(), m_galPanel->GetView(), - m_galPanel->GetViewControls(), nullptr ); + m_galPanel->GetViewControls(), nullptr ); m_pcbActions = std::make_unique( ); m_toolDispatcher = std::make_unique( m_toolManager.get() ); @@ -156,6 +159,7 @@ void PCB_TEST_FRAME_BASE::createView( wxWindow *aParent, PCB_DRAW_PANEL_GAL::GAL //SetBoard( std::make_shared( new BOARD )); } + PCB_TEST_FRAME_BASE::PCB_TEST_FRAME_BASE() { } @@ -166,6 +170,7 @@ PCB_TEST_FRAME_BASE::~PCB_TEST_FRAME_BASE() } + void PCB_TEST_FRAME_BASE::LoadSettings() { auto cs = Pgm().GetSettingsManager().GetColorSettings(); diff --git a/qa/qa_utils/test_app_main.cpp b/qa/qa_utils/test_app_main.cpp index 58b48f7014..02c7748a5e 100644 --- a/qa/qa_utils/test_app_main.cpp +++ b/qa/qa_utils/test_app_main.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2014 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2014-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 @@ -24,14 +24,12 @@ /* - - This is a program launcher for a single KIFACE DSO. It only mimics a KIWAY, - not actually implements one, since only a single DSO is supported by it. - - It is compiled multiple times, once for each standalone program and as such - gets different compiler command line supplied #defines from CMake. - -*/ + * This is a program launcher for a single KIFACE DSO. It only mimics a KIWAY, + * not actually implements one, since only a single DSO is supported by it. + * + * It is compiled multiple times, once for each standalone program and as such + * gets different compiler command line supplied #defines from CMake. + */ #include @@ -66,32 +64,34 @@ static struct IFACE : public KIFACE_I void OnKifaceEnd() override {} - wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override + wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, + int aCtlBits = 0 ) override { assert( false ); return nullptr; } /** - * Function IfaceOrAddress - * return a pointer to the requested object. The safest way to use this - * is to retrieve a pointer to a static instance of an interface, similar to - * how the KIFACE interface is exported. But if you know what you are doing + * Return a pointer to the requested object. + * + * The safest way to use this is to retrieve a pointer to a static instance of an interface, + * similar to how the KIFACE interface is exported. But if you know what you are doing * use it to retrieve anything you want. * * @param aDataId identifies which object you want the address of. - * - * @return void* - and must be cast into the know type. + * @return the requested object which must be cast into the know type. */ void* IfaceOrAddress( int aDataId ) override { - return NULL; + return nullptr; } } kiface( "pcb_test_frame", KIWAY::FACE_PCB ); + KIWAY Kiway( &Pgm(), KFCTL_STANDALONE ); + static struct PGM_TEST_FRAME : public PGM_BASE { bool OnPgmInit(); @@ -128,6 +128,7 @@ static struct PGM_TEST_FRAME : public PGM_BASE } program; + PGM_BASE& Pgm() { return program; @@ -147,10 +148,10 @@ KIFACE_I& Kiface() return kiface; } + /** - * Struct APP_SINGLE_TOP - * implements a bare naked wxApp (so that we don't become dependent on - * functionality in a wxApp derivative that we cannot deliver under wxPython). + * Implement a bare naked wxApp (so that we don't become dependent on functionality in a wxApp + * derivative that we cannot deliver under wxPython). */ struct APP_TEST : public wxApp { @@ -181,8 +182,7 @@ struct APP_TEST : public wxApp catch( const std::exception& e ) { wxLogError( wxT( "Unhandled exception class: %s what: %s" ), - FROM_UTF8( typeid(e).name() ), - FROM_UTF8( e.what() ) ); + FROM_UTF8( typeid(e).name() ), FROM_UTF8( e.what() ) ); } catch( const IO_ERROR& ioe ) { @@ -195,8 +195,6 @@ struct APP_TEST : public wxApp program.OnPgmExit(); - - return false; } @@ -240,14 +238,17 @@ bool PGM_TEST_FRAME::OnPgmInit() return true; } + void SetTopFrame ( wxFrame* aFrame ) { Pgm().App().SetTopWindow( aFrame ); // wxApp gets a face. aFrame->Show(); } + IMPLEMENT_APP_NO_MAIN(APP_TEST); + #ifndef TEST_APP_NO_MAIN int main( int argc, char** argv ) @@ -269,4 +270,4 @@ int main( int argc, char** argv ) return ret; } -#endif \ No newline at end of file +#endif