From c90a3efea21d84cb84775f7a5cde798a676596d5 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 29 Aug 2018 23:37:20 +0100 Subject: [PATCH] Change KIDIALOG hashing algorithm to __FILE__ + __LINE__. Using Title + Message wasn't working for all the dialogs which did substitutions in the message (which was a lot of them). Fixes: lp:1789348 * https://bugs.launchpad.net/kicad/+bug/1789348 --- common/confirm.cpp | 18 ++++++++---------- common/dialogs/dialog_configure_paths.cpp | 2 +- eeschema/dialogs/dialog_annotate.cpp | 4 ++-- eeschema/lib_export.cpp | 2 +- eeschema/pinedit.cpp | 2 +- include/confirm.h | 8 +------- kicad/import_project.cpp | 2 +- kicad/prjconfig.cpp | 2 +- pcbnew/dialogs/dialog_copper_zones.cpp | 2 +- pcbnew/dialogs/dialog_export_idf.cpp | 2 +- .../dialogs/dialog_gencad_export_options.cpp | 2 +- pcbnew/dialogs/dialog_track_via_properties.cpp | 2 +- pcbnew/footprint_libraries_utils.cpp | 2 +- pcbnew/router/pns_kicad_iface.cpp | 2 +- pcbnew/router/router_tool.cpp | 4 ++-- pcbnew/tools/placement_tool.cpp | 2 +- pcbnew/zone_filler.cpp | 2 +- 17 files changed, 26 insertions(+), 34 deletions(-) diff --git a/common/confirm.cpp b/common/confirm.cpp index 59b7853bc8..d22120860e 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -46,7 +46,6 @@ KIDIALOG::KIDIALOG( wxWindow* aParent, const wxString& aMessage, const wxString& aCaption, long aStyle ) : wxRichMessageDialog( aParent, aMessage, aCaption, aStyle | wxCENTRE ) { - setHash(); } @@ -54,7 +53,14 @@ KIDIALOG::KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType, const wxString& aCaption ) : wxRichMessageDialog( aParent, aMessage, getCaption( aType, aCaption ), getStyle( aType ) ) { - setHash(); +} + + +void KIDIALOG::DoNotShowCheckbox( wxString aUniqueId, int line ) +{ + ShowCheckBox( _( "Do not show again" ), false ); + + m_hash = std::hash{}( aUniqueId ) + line; } @@ -110,14 +116,6 @@ int KIDIALOG::ShowModal() } -void KIDIALOG::setHash() -{ - std::size_t h1 = std::hash{}( GetMessage() ); - std::size_t h2 = std::hash{}( GetTitle() ); - m_hash = h1 ^ ( h2 << 1 ); -} - - wxString KIDIALOG::getCaption( KD_TYPE aType, const wxString& aCaption ) { if( !aCaption.IsEmpty() ) diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp index 0d4e0304f7..6d8586a6aa 100644 --- a/common/dialogs/dialog_configure_paths.cpp +++ b/common/dialogs/dialog_configure_paths.cpp @@ -328,7 +328,7 @@ void DIALOG_CONFIGURE_PATHS::OnGridCellChanging( wxGridEvent& event ) "the external environment variable(s) from your system." ); KIDIALOG dlg( this, msg1, KIDIALOG::KD_WARNING ); dlg.ShowDetailedText( msg2 ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); dlg.ShowModal(); } else if( col == EV_NAME_COL && m_EnvVars->GetCellValue( row, EV_NAME_COL ) != text ) diff --git a/eeschema/dialogs/dialog_annotate.cpp b/eeschema/dialogs/dialog_annotate.cpp index 7dcdfcf0e5..23a4935874 100644 --- a/eeschema/dialogs/dialog_annotate.cpp +++ b/eeschema/dialogs/dialog_annotate.cpp @@ -215,7 +215,7 @@ void DIALOG_ANNOTATE::OnApplyClick( wxCommandEvent& event ) KIDIALOG dlg( this, message, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Clear and Annotate" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( dlg.ShowModal() == wxCANCEL ) return; @@ -261,7 +261,7 @@ void DIALOG_ANNOTATE::OnClearAnnotationCmpClick( wxCommandEvent& event ) KIDIALOG dlg( this, message, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Clear Annotation" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( dlg.ShowModal() == wxID_CANCEL ) return; diff --git a/eeschema/lib_export.cpp b/eeschema/lib_export.cpp index ff2e17db32..96e9dfa8cd 100644 --- a/eeschema/lib_export.cpp +++ b/eeschema/lib_export.cpp @@ -152,7 +152,7 @@ void LIB_EDIT_FRAME::OnExportPart( wxCommandEvent& event ) KIDIALOG errorDlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); errorDlg.SetOKLabel( _( "Overwrite" ) ); - errorDlg.DoNotShowCheckbox(); + errorDlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( errorDlg.ShowModal() == wxID_CANCEL ) return; diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index c4cc60168c..c72240bc8d 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -210,7 +210,7 @@ void LIB_EDIT_FRAME::PlacePin() KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Create Pin Anyway" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); bool status = dlg.ShowModal() == wxID_OK; diff --git a/include/confirm.h b/include/confirm.h index 8ff4c830f0..f13e8018c2 100644 --- a/include/confirm.h +++ b/include/confirm.h @@ -51,10 +51,7 @@ public: KIDIALOG( wxWindow* aParent, const wxString& aMessage, KD_TYPE aType, const wxString& aCaption = "" ); ///> Shows the 'do not show again' checkbox - void DoNotShowCheckbox() - { - ShowCheckBox( _( "Do not show again" ), false ); - } + void DoNotShowCheckbox( wxString file, int line ); ///> Checks the 'do not show again' setting for the dialog bool DoNotShowAgain() const; @@ -64,9 +61,6 @@ public: int ShowModal() override; protected: - ///> Sets the dialog hash value - void setHash(); - ///> Unique identifier of the dialog unsigned long m_hash; diff --git a/kicad/import_project.cpp b/kicad/import_project.cpp index e8ca9ef58f..201c63654c 100644 --- a/kicad/import_project.cpp +++ b/kicad/import_project.cpp @@ -99,7 +99,7 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event ) "want to create a new empty directory for the project?" ); KIDIALOG dlg( this, msg, _( "Confirmation" ), wxYES_NO | wxICON_WARNING ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( dlg.ShowModal() == wxID_YES ) { diff --git a/kicad/prjconfig.cpp b/kicad/prjconfig.cpp index 74886b45ed..45b84faf51 100644 --- a/kicad/prjconfig.cpp +++ b/kicad/prjconfig.cpp @@ -365,7 +365,7 @@ void KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate( wxCommandEvent& event ) _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); msgDlg.SetExtendedMessage( extendedMsg ); msgDlg.SetOKLabel( _( "Overwrite" ) ); - msgDlg.DoNotShowCheckbox(); + msgDlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( msgDlg.ShowModal() == wxID_CANCEL ) return; diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 042e28e2ae..d8699c647b 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -230,7 +230,7 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly ) KIDIALOG dlg( this, _( "The legacy segment fill mode is not recommended." "Convert zone to polygon fill? "), _( "Legacy Warning" ), wxYES_NO | wxICON_WARNING ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( dlg.ShowModal() == wxYES ) m_settings.m_FillMode = ZFM_POLYGONS; diff --git a/pcbnew/dialogs/dialog_export_idf.cpp b/pcbnew/dialogs/dialog_export_idf.cpp index 1de1861024..e9e16bfbca 100644 --- a/pcbnew/dialogs/dialog_export_idf.cpp +++ b/pcbnew/dialogs/dialog_export_idf.cpp @@ -170,7 +170,7 @@ bool DIALOG_EXPORT_IDF3::TransferDataFromWindow() wxString msg = wxString::Format( _( "File %s already exists." ), fn.GetPath() ); KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Overwrite" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); return ( dlg.ShowModal() == wxID_OK ); } diff --git a/pcbnew/dialogs/dialog_gencad_export_options.cpp b/pcbnew/dialogs/dialog_gencad_export_options.cpp index 92b5972922..af23b9f73b 100644 --- a/pcbnew/dialogs/dialog_gencad_export_options.cpp +++ b/pcbnew/dialogs/dialog_gencad_export_options.cpp @@ -125,7 +125,7 @@ bool DIALOG_GENCAD_EXPORT_OPTIONS::TransferDataFromWindow() wxString msg = wxString::Format( _( "File %s already exists." ), fn ); KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Overwrite" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); return ( dlg.ShowModal() == wxID_OK ); } diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index aa954a843a..0014ad6a69 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -328,7 +328,7 @@ bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector& c KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Continue" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); return dlg.ShowModal() == wxID_OK; } diff --git a/pcbnew/footprint_libraries_utils.cpp b/pcbnew/footprint_libraries_utils.cpp index 12977836ba..b1d7fa3fc0 100644 --- a/pcbnew/footprint_libraries_utils.cpp +++ b/pcbnew/footprint_libraries_utils.cpp @@ -490,7 +490,7 @@ wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary(const wxString& aLibName ) wxString msg = wxString::Format( _( "Library %s already exists." ), libPath ); KIDIALOG dlg( this, msg, _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Overwrite" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( dlg.ShowModal() == wxID_CANCEL ) return wxEmptyString; diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index e48819a8ac..3b4f011f3e 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -804,7 +804,7 @@ bool PNS_KICAD_IFACE::syncZone( PNS::NODE* aWorld, ZONE_CONTAINER* aZone ) wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n" "Please verify it is not a self-intersecting polygon." ), aZone->GetSelectMenuText( MILLIMETRES ) ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); dlg.ShowModal(); return false; diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 3675887993..0d7fe15ab9 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1008,7 +1008,7 @@ void ROUTER_TOOL::performDragging( int aMode ) KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Drag Anyway" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( dlg.ShowModal() == wxID_CANCEL ) return; @@ -1162,7 +1162,7 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent ) KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Drag Anyway" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( dlg.ShowModal() == wxID_CANCEL ) return 0; diff --git a/pcbnew/tools/placement_tool.cpp b/pcbnew/tools/placement_tool.cpp index 08b0d3c13e..dfcad89c1a 100644 --- a/pcbnew/tools/placement_tool.cpp +++ b/pcbnew/tools/placement_tool.cpp @@ -241,7 +241,7 @@ int ALIGN_DISTRIBUTE_TOOL::checkLockedStatus( const SELECTION &selection ) const _( "Selection contains locked items. Do you want to continue?" ), _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Continue" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( dlg.ShowModal() == wxID_OK ) return SELECTION_LOCK_OVERRIDE; diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 3cca62020a..6983b34a0a 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -196,7 +196,7 @@ bool ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) _( "Zone fills are out-of-date. Refill?" ), _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKCancelLabels( _( "Refill" ), _( "Continue without Refill" ) ); - dlg.DoNotShowCheckbox(); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); refill = ( dlg.ShowModal() == wxID_OK );