From f399dc0c3a077e5966a4aeffdebcc1d69ab9df35 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 18 Jan 2023 01:16:57 +0000 Subject: [PATCH] Nullptr safety. (Sentry KICAD-4F) --- common/drawing_sheet/ds_draw_item.cpp | 2 +- common/drawing_sheet/ds_painter.cpp | 4 ++-- include/drawing_sheet/ds_draw_item.h | 10 ++++------ pagelayout_editor/pl_draw_panel_gal.cpp | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/common/drawing_sheet/ds_draw_item.cpp b/common/drawing_sheet/ds_draw_item.cpp index 98b542e141..1b2d27108e 100644 --- a/common/drawing_sheet/ds_draw_item.cpp +++ b/common/drawing_sheet/ds_draw_item.cpp @@ -492,7 +492,7 @@ void DS_DRAW_ITEM_LIST::BuildDrawItemsList( const PAGE_INFO& aPageInfo, DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance(); m_titleBlock = &aTitleBlock; - m_paperFormat = &aPageInfo.GetType(); + m_paperFormat = aPageInfo.GetType(); // Build the basic layout shape, if the layout list is empty if( model.GetCount() == 0 && !model.VoidListAllowed() ) diff --git a/common/drawing_sheet/ds_painter.cpp b/common/drawing_sheet/ds_painter.cpp index a3b9a16c67..dc10020416 100644 --- a/common/drawing_sheet/ds_painter.cpp +++ b/common/drawing_sheet/ds_painter.cpp @@ -156,12 +156,12 @@ wxString DS_DRAW_ITEM_LIST::BuildFullText( const wxString& aTextbase ) } else if( token->IsSameAs( wxT( "PAPER" ) ) ) { - *token = m_paperFormat ? *m_paperFormat : wxString( "" ); + *token = m_paperFormat; tokenUpdated = true; } else if( token->IsSameAs( wxT( "LAYER" ) ) ) { - *token = m_sheetLayer ? *m_sheetLayer : wxString( "" ); + *token = m_sheetLayer; tokenUpdated = true; } else if( m_titleBlock ) diff --git a/include/drawing_sheet/ds_draw_item.h b/include/drawing_sheet/ds_draw_item.h index 408b708c85..dea9570379 100644 --- a/include/drawing_sheet/ds_draw_item.h +++ b/include/drawing_sheet/ds_draw_item.h @@ -391,9 +391,7 @@ public: m_penSize = 1; m_pageNumber = "1"; m_sheetCount = 1; - m_sheetLayer = nullptr; m_titleBlock = nullptr; - m_paperFormat = nullptr; m_project = nullptr; m_isFirstPage = true; m_properties = nullptr; @@ -421,7 +419,7 @@ public: /** * Set the paper format name (mainly for drawing sheet editor) */ - void SetPaperFormat( const wxString* aFormatName ) { m_paperFormat = aFormatName; } + void SetPaperFormat( const wxString& aFormatName ) { m_paperFormat = aFormatName; } /** * Set the filename to draw/plot @@ -441,7 +439,7 @@ public: /** * Set the sheet layer to draw/plot */ - void SetSheetLayer( const wxString& aSheetLayer ) { m_sheetLayer = &aSheetLayer; } + void SetSheetLayer( const wxString& aSheetLayer ) { m_sheetLayer = aSheetLayer; } void SetDefaultPenSize( int aPenSize ) { m_penSize = aPenSize; } int GetDefaultPenSize() const { return m_penSize; } @@ -550,12 +548,12 @@ protected: int m_sheetCount; ///< The number of sheets // for text variable references, in schematic const TITLE_BLOCK* m_titleBlock; // for text variable references - const wxString* m_paperFormat; // for text variable references + wxString m_paperFormat; // for text variable references wxString m_fileName; // for text variable references wxString m_sheetName; // for text variable references wxString m_sheetPath; // for text variable references wxString m_pageNumber; ///< The actual page number displayed in the title block. - const wxString* m_sheetLayer; // for text variable references + wxString m_sheetLayer; // for text variable references const PROJECT* m_project; // for project-based text variable references const std::map* m_properties; // for text variable references diff --git a/pagelayout_editor/pl_draw_panel_gal.cpp b/pagelayout_editor/pl_draw_panel_gal.cpp index d56e2e81c3..ef6f254e44 100644 --- a/pagelayout_editor/pl_draw_panel_gal.cpp +++ b/pagelayout_editor/pl_draw_panel_gal.cpp @@ -98,7 +98,7 @@ void PL_DRAW_PANEL_GAL::DisplayDrawingSheet() // To show the formatted texts instead of raw texts in drawing sheet editor, we need // a dummy DS_DRAW_ITEM_LIST. DS_DRAW_ITEM_LIST dummy; - dummy.SetPaperFormat( &m_edaFrame->GetPageSettings().GetType() ); + dummy.SetPaperFormat( m_edaFrame->GetPageSettings().GetType() ); dummy.SetTitleBlock( &m_edaFrame->GetTitleBlock() ); dummy.SetProject( &m_edaFrame->Prj() ); dummy.SetMilsToIUfactor( drawSheetIUScale.IU_PER_MILS );