Skip to content

Commit

Permalink
Cleanups: Dangling pointers, unused variables, signness
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerhard Stein committed Oct 27, 2024
1 parent 468681c commit a407728
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/filtertransdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions src/import_export/univcsvdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -613,7 +613,7 @@ void mmUnivCSVDialog::initDelimiter()

}

void mmUnivCSVDialog::OnShowPayeeDialog(wxMouseEvent& event)
void mmUnivCSVDialog::OnShowPayeeDialog(wxMouseEvent&)
{
wxString payeeName;
if (payeeListBox_->GetSelectedRow() >= 0) {
Expand All @@ -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)
Expand Down Expand Up @@ -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()));
}
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -2770,7 +2770,7 @@ void mmUnivCSVDialog::OnCheckboxClick(wxCommandEvent& event)
}
}

void mmUnivCSVDialog::OnMenuSelected(wxCommandEvent& event)
void mmUnivCSVDialog::OnMenuSelected(wxCommandEvent&)
{
colorButton_->Enable(false);
colorCheckBox_->SetValue(false);
Expand Down
10 changes: 5 additions & 5 deletions src/import_export/univcsvdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
Expand All @@ -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();
Expand Down
10 changes: 5 additions & 5 deletions src/mmSimpleDialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -731,7 +731,7 @@ void mmDatePickerCtrl::OnDateChanged(wxDateEvent& event)
event.Skip();
}

void mmDatePickerCtrl::OnDateSpin(wxSpinEvent& event)
void mmDatePickerCtrl::OnDateSpin(wxSpinEvent&)
{
if (spinButton_)
{
Expand Down Expand Up @@ -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.");
Expand Down
8 changes: 4 additions & 4 deletions src/mmSimpleDialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<wxString, int> all_elements_;
Expand All @@ -163,8 +163,8 @@ class mmComboBoxAccount : public mmComboBox
protected:
void init();
private:
int accountID_;
bool excludeClosed_;
int accountID_ = -1;
bool excludeClosed_ = true;
};

/* -------------------------------------------- */
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/payeedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/relocatepayeedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void relocatePayeeDialog::OnFocusChange(wxChildFocusEvent& event)
event.Skip();
}

void relocatePayeeDialog::OnTextUpdated(wxCommandEvent& event)
void relocatePayeeDialog::OnTextUpdated(wxCommandEvent&)
{
IsOkOk();
}
2 changes: 1 addition & 1 deletion src/relocatepayeedialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit a407728

Please sign in to comment.