From a4077283a7516a63237e3bca22d155d333911628 Mon Sep 17 00:00:00 2001 From: Gerhard Stein Date: Sun, 27 Oct 2024 13:52:33 +0100 Subject: [PATCH] Cleanups: Dangling pointers, unused variables, signness --- src/filtertransdialog.cpp | 2 +- src/import_export/univcsvdialog.cpp | 24 ++++++++++++------------ src/import_export/univcsvdialog.h | 10 +++++----- src/mmSimpleDialogs.cpp | 10 +++++----- src/mmSimpleDialogs.h | 8 ++++---- src/payeedialog.h | 2 +- src/relocatepayeedialog.cpp | 2 +- src/relocatepayeedialog.h | 2 +- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/filtertransdialog.cpp b/src/filtertransdialog.cpp index 3287aa7d2c..a282c99049 100644 --- a/src/filtertransdialog.cpp +++ b/src/filtertransdialog.cpp @@ -1496,7 +1496,7 @@ int mmFilterTransactionsDialog::mmIsRecordMatches(const Model_Checking::Data& tr for (const auto& split : it->second) { // Need to check if the split matches using the transaction Notes & Tags as well - Model_Checking::Data splitWithTxnNotes = tran; + Model_Checking::Data splitWithTxnNotes(tran); splitWithTxnNotes.CATEGID = split.CATEGID; splitWithTxnNotes.TRANSAMOUNT = split.SPLITTRANSAMOUNT; Model_Checking::Data splitWithSplitNotes = splitWithTxnNotes; diff --git a/src/import_export/univcsvdialog.cpp b/src/import_export/univcsvdialog.cpp index 9bc6ee02bf..28813d67c1 100644 --- a/src/import_export/univcsvdialog.cpp +++ b/src/import_export/univcsvdialog.cpp @@ -198,7 +198,7 @@ void mmUnivCSVDialog::CreateControls() m_text_ctrl_->Connect(ID_FILE_NAME , wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(mmUnivCSVDialog::OnFileNameEntered), nullptr, this); - const wxString& file_button_label = _("&Browse..."); + const auto file_button_label = wxString("&Browse..."); wxButton* button_browse = new wxButton(itemPanel6, wxID_BROWSE, file_button_label); itemBoxSizer7->Add(button_browse, g_flagsH); @@ -387,7 +387,7 @@ void mmUnivCSVDialog::CreateControls() flex_sizer->Add(itemStaticText88, g_flagsH); m_choiceEncoding = new wxChoice(itemPanel7, ID_ENCODING); - for (const auto i : g_encoding) + for (const auto &i : g_encoding) m_choiceEncoding->Append(wxGetTranslation(i.second.second), new wxStringClientData(i.second.second)); m_choiceEncoding->SetSelection(0); @@ -557,7 +557,7 @@ void mmUnivCSVDialog::CreateControls() itemClearButton->Connect(wxID_CLEAR, wxEVT_COMMAND_BUTTON_CLICKED , wxCommandEventHandler(mmUnivCSVDialog::OnButtonClear), nullptr, this); - const wxString& file_tooltip = IsImporter() + const wxString file_tooltip = IsImporter() ? (IsXML() ? _("Choose XML data file to Import") : _("Choose CSV data file to Import")) : (IsXML() ? _("Choose XML data file to Export") : _("Choose CSV data file to Export")); mmToolTip(button_browse, file_tooltip); @@ -613,7 +613,7 @@ void mmUnivCSVDialog::initDelimiter() } -void mmUnivCSVDialog::OnShowPayeeDialog(wxMouseEvent& event) +void mmUnivCSVDialog::OnShowPayeeDialog(wxMouseEvent&) { wxString payeeName; if (payeeListBox_->GetSelectedRow() >= 0) { @@ -632,7 +632,7 @@ void mmUnivCSVDialog::OnShowPayeeDialog(wxMouseEvent& event) } } -void mmUnivCSVDialog::OnShowCategDialog(wxMouseEvent& event) +void mmUnivCSVDialog::OnShowCategDialog(wxMouseEvent&) { int id = -1; if (categoryListBox_->GetSelectedRow() >= 0) @@ -660,12 +660,12 @@ void mmUnivCSVDialog::OnShowCategDialog(wxMouseEvent& event) void mmUnivCSVDialog::OnColumnResize(wxListEvent& event) { - int col = event.GetColumn(); + const unsigned int col = event.GetColumn(); if (col == 0 || col > csvFieldOrder_.size()) return; csvFieldOrder_.at(col - 1).second = m_list_ctrl_->GetColumnWidth(col); } -void mmUnivCSVDialog::OnSettingsSelected(wxCommandEvent& event) +void mmUnivCSVDialog::OnSettingsSelected(wxCommandEvent&) { SetSettings(GetStoredSettings(m_choice_preset_name->GetSelection())); } @@ -822,7 +822,7 @@ void mmUnivCSVDialog::SetSettings(const wxString &json_data) Value a = json_doc["FIELD_WIDTHS"].GetArray(); if (a.IsArray()) { - int col = 0; + unsigned int col = 0; for (auto& v : a.GetArray()) { const auto value = v.GetInt(); @@ -1342,7 +1342,7 @@ void mmUnivCSVDialog::OnImport(wxCommandEvent& WXUNUSED(event)) const long linesToImport = lastRow - firstRow; long countEmptyLines = 0; int color_id = colorCheckBox_->IsChecked() ? colorButton_->GetColorId() : -1; - if (colorCheckBox_->IsChecked() && color_id < 0 || color_id > 7) { + if (colorCheckBox_->IsChecked() && (color_id < 0 || color_id > 7) ) { return mmErrorDialogs::ToolTip4Object(colorButton_, _("Color"), _("Invalid value"), wxICON_ERROR); } @@ -2280,7 +2280,7 @@ void mmUnivCSVDialog::OnListBox(wxCommandEvent& event) OnRemove(event); } -void mmUnivCSVDialog::OnDelimiterChange(wxCommandEvent& event) +void mmUnivCSVDialog::OnDelimiterChange(wxCommandEvent&) { wxString delimit = m_textDelimiter->GetValue(); @@ -2585,7 +2585,7 @@ void mmUnivCSVDialog::parseToken(int index, const wxString& orig_token, tran_hol } else { - for (const wxString& entry : { "debit", "deposit", "+" }) { + for (const wxString entry : { "debit", "deposit", "+" }) { if (entry.CmpNoCase(token) == 0) { holder.Type = Model_Checking::TYPE_STR_DEPOSIT; break; @@ -2770,7 +2770,7 @@ void mmUnivCSVDialog::OnCheckboxClick(wxCommandEvent& event) } } -void mmUnivCSVDialog::OnMenuSelected(wxCommandEvent& event) +void mmUnivCSVDialog::OnMenuSelected(wxCommandEvent&) { colorButton_->Enable(false); colorCheckBox_->SetValue(false); diff --git a/src/import_export/univcsvdialog.h b/src/import_export/univcsvdialog.h index 0039c66e98..e78c15bcbc 100644 --- a/src/import_export/univcsvdialog.h +++ b/src/import_export/univcsvdialog.h @@ -225,7 +225,7 @@ class mmUnivCSVDialog: public wxDialog void OnFileBrowse(wxCommandEvent& event); void OnListBox(wxCommandEvent& event); void OnColumnResize(wxListEvent& event); - void OnDelimiterChange(wxCommandEvent& event); + void OnDelimiterChange(wxCommandEvent&); void OnDecimalChange(wxCommandEvent& event); void OnButtonClear(wxCommandEvent& event); void OnFileNameEntered(wxCommandEvent& event); @@ -234,9 +234,9 @@ class mmUnivCSVDialog: public wxDialog void changeFocus(wxChildFocusEvent& event); void OnSpinCtrlIgnoreRows(wxSpinEvent& event); void OnCheckboxClick(wxCommandEvent& event); - void OnMenuSelected(wxCommandEvent& event); - void OnShowPayeeDialog(wxMouseEvent& event); - void OnShowCategDialog(wxMouseEvent& event); + void OnMenuSelected(wxCommandEvent&); + void OnShowPayeeDialog(wxMouseEvent&); + void OnShowCategDialog(wxMouseEvent&); void saveAccountPresets(); bool validateCustomFieldData(int fieldId, wxString& value, wxString& log_message); private: @@ -251,7 +251,7 @@ class mmUnivCSVDialog: public wxDialog void validateCategories(); bool ShowToolTips(); - void OnSettingsSelected(wxCommandEvent& event); + void OnSettingsSelected(wxCommandEvent&); const wxString GetStoredSettings(int id) const; void SetSettings(const wxString &data); ITransactionsFile *CreateFileHandler(); diff --git a/src/mmSimpleDialogs.cpp b/src/mmSimpleDialogs.cpp index 854fa9901d..88a4ac5491 100644 --- a/src/mmSimpleDialogs.cpp +++ b/src/mmSimpleDialogs.cpp @@ -311,7 +311,7 @@ mmComboBox::mmComboBox(wxWindow* parent, wxWindowID id, wxSize size) Bind(wxEVT_CHAR, &mmComboBox::OnKeyPressed, this); } -void mmComboBox::OnDropDown(wxCommandEvent& event) +void mmComboBox::OnDropDown(wxCommandEvent&) { wxFocusEvent evt; OnSetFocus(evt); @@ -471,8 +471,8 @@ void mmComboBoxAccount::init() mmComboBoxAccount::mmComboBoxAccount(wxWindow* parent, wxWindowID id , wxSize size, int accountID, bool excludeClosed) : mmComboBox(parent, id, size) - , excludeClosed_(excludeClosed) , accountID_(accountID) + , excludeClosed_(excludeClosed) { init(); wxArrayString choices; @@ -608,7 +608,7 @@ mmComboBoxCustom::mmComboBoxCustom(wxWindow* parent, wxArrayString& a, wxWindowI mmDatePickerCtrl::mmDatePickerCtrl(wxWindow* parent, wxWindowID id, wxDateTime dt, wxPoint pos, wxSize size, long style) : wxPanel(parent, id, pos, size, style) - , parent_(parent), dt_(dt) + , dt_(dt), parent_(parent) { if (!dt.IsValid()) dt_ = wxDateTime::Now(); @@ -731,7 +731,7 @@ void mmDatePickerCtrl::OnDateChanged(wxDateEvent& event) event.Skip(); } -void mmDatePickerCtrl::OnDateSpin(wxSpinEvent& event) +void mmDatePickerCtrl::OnDateSpin(wxSpinEvent&) { if (spinButton_) { @@ -1017,7 +1017,7 @@ void mmErrorDialogs::InvalidFile(wxWindow *object, bool open) void mmErrorDialogs::InvalidAccount(wxWindow *object, bool transfer, TOOL_TIP tm) { - const wxString& errorHeader = _("Invalid Account"); + const auto errorHeader = wxString("Invalid Account"); wxString errorMessage; if (!transfer) errorMessage = _("Please select the account for this transaction."); diff --git a/src/mmSimpleDialogs.h b/src/mmSimpleDialogs.h index f5dec1f005..6f6fb41e4f 100644 --- a/src/mmSimpleDialogs.h +++ b/src/mmSimpleDialogs.h @@ -142,7 +142,7 @@ class mmComboBox : public wxComboBox protected: void OnTextUpdated(wxCommandEvent& event); void OnSetFocus(wxFocusEvent& event); - void OnDropDown(wxCommandEvent& event); + void OnDropDown(wxCommandEvent&); void OnKeyPressed(wxKeyEvent& event); virtual void init() = 0; std::map all_elements_; @@ -163,8 +163,8 @@ class mmComboBoxAccount : public mmComboBox protected: void init(); private: - int accountID_; - bool excludeClosed_; + int accountID_ = -1; + bool excludeClosed_ = true; }; /* -------------------------------------------- */ @@ -267,7 +267,7 @@ class mmDatePickerCtrl : public wxPanel wxDatePickerCtrl* datePicker_ = nullptr; wxTimePickerCtrl* timePicker_ = nullptr; void OnDateChanged(wxDateEvent& event); - void OnDateSpin(wxSpinEvent& event); + void OnDateSpin(wxSpinEvent&); wxWindow* parent_ = nullptr; wxStaticText* itemStaticTextWeek_ = nullptr; diff --git a/src/payeedialog.h b/src/payeedialog.h index 916d115db3..c5b1a35948 100644 --- a/src/payeedialog.h +++ b/src/payeedialog.h @@ -104,9 +104,9 @@ class mmPayeeDialog : public wxDialog wxBitmapButton* m_magicButton = nullptr; int m_payee_id = -1; + bool m_payee_choose = false; wxString m_init_selected_payee; int m_payee_rename = -1; - bool m_payee_choose = false; wxString m_maskStr; int m_sort = cols::PAYEE_NAME, m_lastSort = cols::PAYEE_NAME; bool refreshRequested_ = false, m_sortReverse = false; diff --git a/src/relocatepayeedialog.cpp b/src/relocatepayeedialog.cpp index 3240c6a512..01fcaf0c48 100644 --- a/src/relocatepayeedialog.cpp +++ b/src/relocatepayeedialog.cpp @@ -222,7 +222,7 @@ void relocatePayeeDialog::OnFocusChange(wxChildFocusEvent& event) event.Skip(); } -void relocatePayeeDialog::OnTextUpdated(wxCommandEvent& event) +void relocatePayeeDialog::OnTextUpdated(wxCommandEvent&) { IsOkOk(); } diff --git a/src/relocatepayeedialog.h b/src/relocatepayeedialog.h index 6bd6a7cde3..d85e7687bb 100644 --- a/src/relocatepayeedialog.h +++ b/src/relocatepayeedialog.h @@ -49,7 +49,7 @@ class relocatePayeeDialog : public wxDialog void IsOkOk(); void OnOk(wxCommandEvent& event); void OnCancel(wxCommandEvent& event); - void OnTextUpdated(wxCommandEvent& event); + void OnTextUpdated(wxCommandEvent&); void OnFocusChange(wxChildFocusEvent& event);