Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed memleaks and predefinedfilterscombobox and abstractlogview #730

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ui/include/predefinedfilterscombobox.h
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ class PredefinedFiltersComboBox final : public QComboBox {

public:
explicit PredefinedFiltersComboBox( QWidget* parent );
~PredefinedFiltersComboBox();

PredefinedFiltersComboBox( const PredefinedFiltersComboBox& other ) = delete;
PredefinedFiltersComboBox( PredefinedFiltersComboBox&& other ) noexcept = delete;
2 changes: 2 additions & 0 deletions src/ui/src/abstractlogview.cpp
Original file line number Diff line number Diff line change
@@ -536,9 +536,11 @@ AbstractLogView::~AbstractLogView()
try {
if ( quickFind_ ) {
quickFind_->stopSearch();
delete quickFind_;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

leave this change?

}
} catch ( const std::exception& e ) {
LOG_ERROR << "Failed to stop search: " << e.what();
delete quickFind_;
}
}

6 changes: 6 additions & 0 deletions src/ui/src/predefinedfilterscombobox.cpp
Original file line number Diff line number Diff line change
@@ -102,6 +102,11 @@ PredefinedFiltersComboBox::PredefinedFiltersComboBox( QWidget* parent )
setSizeAdjustPolicy( QComboBox::AdjustToContents );
}

PredefinedFiltersComboBox::~PredefinedFiltersComboBox()
{
delete model_;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting this as a parent for the model object in PredefinedFiltersComboBox constructor is a more "Qt" way to manage this without creating explicit destructors.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting this as a parent for the model object in PredefinedFiltersComboBox constructor is a more "Qt" way to manage this without creating explicit destructors.

leave this change?

}

void PredefinedFiltersComboBox::populatePredefinedFilters()
{
model_->clear();
@@ -172,6 +177,7 @@ void PredefinedFiltersComboBox::setTitle( const QString& title )
{
auto* titleItem = new QStandardItem( title );
model_->insertRow( 0, titleItem );
delete titleItem;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand after insertRow call the ownership should be transferred to the model.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand after insertRow call the ownership should be transferred to the model.

leave this change?

}

void PredefinedFiltersComboBox::insertFilters(