diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index be46c93c6..0e5ee62ab 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -121,7 +121,7 @@ LabelDialog::LabelDialog(wxWindow *parent, 5); // Create the main sizer - mGrid = new Grid(this, wxID_ANY); + mGrid = safenew Grid(this, wxID_ANY); vs->Add(mGrid, 1, wxEXPAND | wxALL, 5); // Create the action buttons @@ -162,20 +162,18 @@ LabelDialog::LabelDialog(wxWindow *parent, mTimeEditor = (TimeEditor *) mGrid->GetDefaultEditorForType(GRID_VALUE_TIME); // Initialize and set the track name column attributes - wxGridCellAttr *attr = new wxGridCellAttr(); + wxGridCellAttr *attr; + mGrid->SetColAttr(Col_Track, (attr = safenew wxGridCellAttr)); attr->SetEditor(mChoiceEditor); - mGrid->SetColAttr(Col_Track, attr); mTrackNames.Add(_("New...")); // Initialize and set the time column attributes - attr = new wxGridCellAttr(); - + mGrid->SetColAttr(Col_Stime, (attr = safenew wxGridCellAttr)); // Don't need DecRef() after this GetDefaultRendererForType. attr->SetRenderer(mGrid->GetDefaultRendererForType(GRID_VALUE_TIME)); - attr->SetEditor(mTimeEditor); attr->SetAlignment(wxALIGN_CENTER, wxALIGN_CENTER); - mGrid->SetColAttr(Col_Stime, attr); + mGrid->SetColAttr(Col_Etime, attr->Clone()); // Seems there's a bug in wxGrid. Adding only 1 row does not diff --git a/src/Tags.cpp b/src/Tags.cpp index 80ac6d641..c6af6bf2b 100644 --- a/src/Tags.cpp +++ b/src/Tags.cpp @@ -715,12 +715,15 @@ TagsEditor::TagsEditor(wxWindow * parent, TagsEditor::~TagsEditor() { - delete mGrid; + // This DELETE is not needed because wxWidgets owns the grid. +// DELETE mGrid; + // TODO: Need to figure out if these should be deleted. Looks like the wxGrid // code takes ownership and uses reference counting, but there's been // cases where they show up as memory leaks. -// delete mStringRenderer; -// delete mComboEditor; +// PRL: Fixed the leaks, see commit c87eb0804bc5f40659b133cab6e2ade061959645 +// DELETE mStringRenderer; +// DELETE mComboEditor; } void TagsEditor::PopulateOrExchange(ShuttleGui & S) @@ -740,10 +743,9 @@ void TagsEditor::PopulateOrExchange(ShuttleGui & S) wxDefaultSize, wxSUNKEN_BORDER); - mStringRenderer = new wxGridCellStringRenderer; - mComboEditor = new ComboEditor(wxArrayString(), true); - - mGrid->RegisterDataType(wxT("Combo"), mStringRenderer, mComboEditor); + mGrid->RegisterDataType(wxT("Combo"), + (mStringRenderer = safenew wxGridCellStringRenderer), + (mComboEditor = safenew ComboEditor(wxArrayString(), true))); mGrid->SetColLabelSize(mGrid->GetDefaultRowSize());