More NULL expunging.

This commit is contained in:
Wayne Stambaugh
2021-07-20 07:27:18 -04:00
parent 75190370dd
commit cf00319c85
137 changed files with 4805 additions and 4379 deletions
@@ -57,6 +57,7 @@ PyObject* PYTHON_ACTION_PLUGIN::CallMethod( const char* aMethod, PyObject* aArgl
PyLOCK lock;
PyErr_Clear();
// pFunc is a new reference to the desired method
PyObject* pFunc = PyObject_GetAttrString( m_PyAction, aMethod );
@@ -67,8 +68,8 @@ PyObject* PYTHON_ACTION_PLUGIN::CallMethod( const char* aMethod, PyObject* aArgl
if( PyErr_Occurred() )
{
wxMessageBox( PyErrStringWithTraceback(),
_( "Exception on python action plugin code" ),
wxICON_ERROR | wxOK );
_( "Exception on python action plugin code" ),
wxICON_ERROR | wxOK );
}
if( result )
@@ -88,7 +89,7 @@ PyObject* PYTHON_ACTION_PLUGIN::CallMethod( const char* aMethod, PyObject* aArgl
Py_XDECREF( pFunc );
}
return NULL;
return nullptr;
}
@@ -258,7 +259,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
ACTION_PLUGINS::SetActionRunning( false );
// Get back the undo buffer to fix some modifications
PICKED_ITEMS_LIST* oldBuffer = NULL;
PICKED_ITEMS_LIST* oldBuffer = nullptr;
if( fromEmpty )
{
@@ -313,6 +314,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
{
oldBuffer->PushItem( deletedItemsList.GetItemWrapper( i ) );
}
// Find new footprints
for( FOOTPRINT* item : currentPcb->Footprints() )
{
@@ -379,12 +381,13 @@ void PCB_EDIT_FRAME::buildActionPluginMenus( ACTION_MENU* actionMenu )
{
wxMenuItem* item;
ACTION_PLUGIN* ap = ACTION_PLUGINS::GetAction( ii );
const wxBitmap& bitmap = ap->iconBitmap.IsOk() ? ap->iconBitmap : KiBitmap( BITMAPS::puzzle_piece );
const wxBitmap& bitmap = ap->iconBitmap.IsOk() ? ap->iconBitmap :
KiBitmap( BITMAPS::puzzle_piece );
item = AddMenuItem( actionMenu, wxID_ANY, ap->GetName(), ap->GetDescription(), bitmap );
Connect( item->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginMenu ) );
wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginMenu ) );
ACTION_PLUGINS::SetActionMenu( ii, item->GetId() );
}
@@ -414,11 +417,11 @@ void PCB_EDIT_FRAME::AddActionPluginTools()
else
bitmap = KiScaledBitmap( BITMAPS::puzzle_piece, this );
wxAuiToolBarItem* button = m_mainToolBar->AddTool(
wxID_ANY, wxEmptyString, bitmap, ap->GetName() );
wxAuiToolBarItem* button = m_mainToolBar->AddTool( wxID_ANY, wxEmptyString,
bitmap, ap->GetName() );
Connect( button->GetId(), wxEVT_COMMAND_MENU_SELECTED,
wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginButton ) );
wxCommandEventHandler( PCB_EDIT_FRAME::OnActionPluginButton ) );
// Link action plugin to button
ACTION_PLUGINS::SetActionButton( ap, button->GetId() );
@@ -459,7 +462,8 @@ std::vector<ACTION_PLUGIN*> PCB_EDIT_FRAME::GetOrderedActionPlugins()
}
bool PCB_EDIT_FRAME::GetActionPluginButtonVisible( const wxString& aPluginPath, bool aPluginDefault )
bool PCB_EDIT_FRAME::GetActionPluginButtonVisible( const wxString& aPluginPath,
bool aPluginDefault )
{
auto& settings = m_settings->m_VisibleActionPlugins;
@@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2017-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
@@ -39,12 +39,6 @@
class PYTHON_ACTION_PLUGIN : public ACTION_PLUGIN
{
PyObject* m_PyAction;
PyObject* CallMethod( const char* aMethod,
PyObject* aArglist = NULL );
wxString CallRetStrMethod( const char* aMethod,
PyObject* aArglist = NULL );
public:
PYTHON_ACTION_PLUGIN( PyObject* action );
~PYTHON_ACTION_PLUGIN();
@@ -56,6 +50,11 @@ public:
wxString GetPluginPath() override;
void Run() override;
void* GetObject() override;
private:
PyObject* m_PyAction;
PyObject* CallMethod( const char* aMethod, PyObject* aArglist = nullptr );
wxString CallRetStrMethod( const char* aMethod, PyObject* aArglist = nullptr );
};
@@ -89,7 +89,7 @@ PyObject* PYTHON_FOOTPRINT_WIZARD::CallMethod( const char* aMethod, PyObject* aA
Py_XDECREF( pFunc );
}
return NULL;
return nullptr;
}
@@ -127,8 +127,7 @@ wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod( const char* aMet
if( !PyList_Check( result ) )
{
Py_DECREF( result );
ret.Add( wxT(
"PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, result is not a list" ),
ret.Add( wxT( "PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod, result is not a list" ),
1 );
return ret;
}
@@ -172,7 +171,7 @@ int PYTHON_FOOTPRINT_WIZARD::GetNumParameterPages()
PyLOCK lock;
// Time to call the callback
PyObject* result = CallMethod( "GetNumParameterPages", NULL );
PyObject* result = CallMethod( "GetNumParameterPages", nullptr );
if( result )
{
@@ -327,7 +326,7 @@ void PYTHON_FOOTPRINT_WIZARD::ResetParameters()
{
PyLOCK lock;
CallMethod( "ResetWizard", NULL );
CallMethod( "ResetWizard", nullptr );
}
@@ -339,13 +338,13 @@ FOOTPRINT* PYTHON_FOOTPRINT_WIZARD::GetFootprint( wxString * aMessages )
{
PyLOCK lock;
PyObject* result = CallMethod( "GetFootprint", NULL );
PyObject* result = CallMethod( "GetFootprint", nullptr );
if( aMessages )
*aMessages = CallRetStrMethod( "GetBuildMessages", NULL );
*aMessages = CallRetStrMethod( "GetBuildMessages", nullptr );
if( !result )
return NULL;
return nullptr;
PyObject* obj = PyObject_GetAttrString( result, "this" );
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <[email protected]>
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-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
@@ -40,11 +40,6 @@
class PYTHON_FOOTPRINT_WIZARD : public FOOTPRINT_WIZARD
{
PyObject* m_PyWizard;
PyObject* CallMethod( const char* aMethod, PyObject* aArglist = NULL );
wxString CallRetStrMethod( const char* aMethod, PyObject* aArglist = NULL );
wxArrayString CallRetArrayStrMethod( const char* aMethod, PyObject* aArglist = NULL );
public:
PYTHON_FOOTPRINT_WIZARD( PyObject* wizard );
~PYTHON_FOOTPRINT_WIZARD();
@@ -58,14 +53,22 @@ public:
wxArrayString GetParameterTypes( int aPage ) override;
wxArrayString GetParameterValues( int aPage ) override;
wxArrayString GetParameterErrors( int aPage ) override;
// must return an empty string or an error description:
wxString SetParameterValues( int aPage, wxArrayString& aValues ) override;
FOOTPRINT* GetFootprint( wxString * aMessages ) override;
void* GetObject() override;
wxArrayString GetParameterHints( int aPage ) override;
wxArrayString GetParameterDesignators( int aPage = 0) override;
wxArrayString GetParameterDesignators( int aPage = 0 ) override;
void ResetParameters() override;
private:
PyObject* CallMethod( const char* aMethod, PyObject* aArglist = nullptr );
wxString CallRetStrMethod( const char* aMethod, PyObject* aArglist = nullptr );
wxArrayString CallRetArrayStrMethod( const char* aMethod, PyObject* aArglist = nullptr );
PyObject* m_PyWizard;
};
+8 -6
View File
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <[email protected]>
* Copyright (C) 1992-2019 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
@@ -52,8 +52,8 @@
/**
* Run a python method from the pcbnew module.
*
* @param aMethodName is the name of the method (like "pcbnew.myfunction" )
* @param aNames will contain the returned string
* @param aMethodName is the name of the method (like "pcbnew.myfunction" ).
* @param aNames will contain the returned string.
*/
static void pcbnewRunPythonMethodWithReturnedString( const char* aMethodName, wxString& aNames )
{
@@ -84,13 +84,13 @@ static void pcbnewRunPythonMethodWithReturnedString( const char* aMethodName, wx
if( pobj )
{
PyObject* str = PyDict_GetItemString(localDict, "result" );
const char* str_res = NULL;
const char* str_res = nullptr;
if(str)
{
PyObject* temp_bytes = PyUnicode_AsEncodedString( str, "UTF-8", "strict" );
if( temp_bytes != NULL )
if( temp_bytes != nullptr )
{
str_res = PyBytes_AS_STRING( temp_bytes );
aNames = FROM_UTF8( str_res );
@@ -98,7 +98,7 @@ static void pcbnewRunPythonMethodWithReturnedString( const char* aMethodName, wx
}
else
{
wxLogMessage( "cannot encode unicode python string" );
wxLogMessage( "cannot encode Unicode python string" );
}
}
else
@@ -151,6 +151,8 @@ void pcbnewGetWizardsBackTrace( wxString& aTrace )
aTrace << "\n**********************************\n";
}
else
{
aTrace += traces[ii] + "\n";
}
}
}
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <[email protected]>
* Copyright (C) 1992-2017 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
@@ -52,8 +52,7 @@
#include <wx/app.h>
static PCB_EDIT_FRAME* s_PcbEditFrame = NULL;
static PCB_EDIT_FRAME* s_PcbEditFrame = nullptr;
static SETTINGS_MANAGER* s_SettingsManager = nullptr;
@@ -62,7 +61,7 @@ BOARD* GetBoard()
if( s_PcbEditFrame )
return s_PcbEditFrame->GetBoard();
else
return NULL;
return nullptr;
}
@@ -188,7 +187,7 @@ bool SaveBoard( wxString& aFileName, BOARD* aBoard, IO_MGR::PCB_FILE_T aFormat )
aBoard->BuildConnectivity();
aBoard->SynchronizeNetsAndNetClasses();
IO_MGR::Save( aFormat, aFileName, aBoard, NULL );
IO_MGR::Save( aFormat, aFileName, aBoard, nullptr );
wxFileName pro = aFileName;
pro.SetExt( ProjectFileExtension );
@@ -267,10 +266,8 @@ bool ExportSpecctraDSN( wxString& aFullFilename )
}
}
bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit,
bool aExport3DFiles, bool aUseRelativePaths,
const wxString& a3D_Subdir,
double aXRef, double aYRef )
bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles,
bool aUseRelativePaths, const wxString& a3D_Subdir, double aXRef, double aYRef )
{
if( s_PcbEditFrame )
{
@@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 NBEE Embedded Systems SL, Miguel Angel Ajo <[email protected]>
* Copyright (C) 2013-2017 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2013-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
@@ -48,73 +48,73 @@ BOARD* LoadBoard( wxString& aFileName );
SETTINGS_MANAGER* GetSettingsManager();
/**
* Constructs a default BOARD with a tempoary (no filename) project
* @return the created board
* Construct a default BOARD with a temporary (no filename) project.
*
* @return the created board.
*/
BOARD* CreateEmptyBoard();
// Boards can be saved only as .kicad_pcb file format,
// so no option to choose the file format.
bool SaveBoard( wxString& aFileName, BOARD* aBoard );
bool SaveBoard( wxString& aFileName, BOARD* aBoard );
/**
* will get the nicknames of all of the footprint libraries configured in
* pcbnew in both the project and global library tables
* @return the list of footprint library nicknames, empty on error
* Get the nicknames of all of the footprint libraries configured in
* pcbnew in both the project and global library tables.
*
* @return the list of footprint library nicknames, empty on error.
*/
wxArrayString GetFootprintLibraries();
/**
* will get the names of all of the footprints available in a footprint library
* @param aNickName is the nickname specifying which footprint library to fetch
* from
* @return the list of footprint names, empty on error
* Get the names of all of the footprints available in a footprint library.
*
* @param aNickName is the nickname specifying which footprint library to fetch from.
* @return the list of footprint names, empty on error.
*/
wxArrayString GetFootprints( const wxString& aNickName );
/**
* will export the current BOARD to a specctra dsn file.
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
* specification.
* Will export the current BOARD to a specctra dsn file.
*
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the specification.
*
* @return true if OK
*/
bool ExportSpecctraDSN( wxString& aFullFilename );
/**
* will export the current BOARD to a VRML (wrl) file.
* Export the current BOARD to a VRML (wrl) file.
*
* See ExportVRML_File in pcb_edit_frame.h for detailed documentation.
* @return true if OK
* @return true if OK.
*/
bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit,
bool aExport3DFiles, bool aUseRelativePaths,
const wxString& a3D_Subdir,
double aXRef, double aYRef );
bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles,
bool aUseRelativePaths, const wxString& a3D_Subdir, double aXRef, double aYRef );
/**
* will import a specctra *.ses file and use it to relocate MODULEs and
* to replace all vias and tracks in an existing and loaded BOARD.
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the
* specification.
* Import a specctra *.ses file and use it to relocate MODULEs and to replace all vias and
* tracks in an existing and loaded #BOARD.
*
* See http://www.autotraxeda.com/docs/SPECCTRA/SPECCTRA.pdf for the specification.
*
* @return true if OK
*/
bool ImportSpecctraSES( wxString& aFullFilename );
/**
* Function ExportFootprintsToLibrary
* Save footprints in a library:
* @param aStoreInNewLib:
* true : save footprints in a existing lib. Existing footprints will be kept
* or updated.
* This lib should be in fp lib table, and is type is .pretty
* false: save footprints in a new lib. It it is an existing lib,
* previous footprints will be removed
*
* @param aLibName:
* optional library name to create, stops dialog call.
* must be called with aStoreInNewLib as true
* @param aStoreInNewLib set to true to save footprints in a existing lib. Existing footprints
* will be kept or updated. This lib should be in fp lib table, and is
* type is .pretty. Set to false to save footprints in a new lib. If it
* is an existing lib, previous footprints will be removed.
*
* @param aLibName is the optional library name to create, stops dialog call. Must be called
* with \a aStoreInNewLib as true.
*/
bool ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName = wxEmptyString,
wxString* aLibPath = NULL );
wxString* aLibPath = nullptr );
/**
* Update the board display after modifying it by a python script
@@ -124,7 +124,7 @@ bool ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName =
* Could be deprecated because modifying a board (especially deleting items) outside
* a action plugin can crash Pcbnew.
*/
void Refresh();
void Refresh();
/**
* Update the layer manager and other widgets from the board setup
@@ -135,7 +135,8 @@ void Refresh();
void UpdateUserInterface();
/**
* Returns the currently selected user unit value for the interface
* Return the currently selected user unit value for the interface.
*
* @return 0 = Inches, 1=mm, -1 if the frame isn't set
*/
int GetUserUnits();
@@ -146,16 +147,16 @@ int GetUserUnits();
bool IsActionRunning();
/**
* Runs the DRC check on the given board and writes the results to a report file.
* Run the DRC check on the given board and writes the results to a report file.
* Requires that the project for the board be loaded, and note that unlike the DRC dialog
* this does not attempt to fill zones, so zones must be valid before calling.
*
* @param aBoard is a valid loaded board
* @param aFileName is the full path and name of the report file to write
* @param aUnits is the units to use in the report
* @param aBoard is a valid loaded board.
* @param aFileName is the full path and name of the report file to write.
* @param aUnits is the units to use in the report.
* @param aReportAllTrackErrors controls whether all errors or just the first error is reported
* for each track
* @return true if successful, false if not
* for each track.
* @return true if successful, false if not.
*/
bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits,
bool aReportAllTrackErrors );