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 various memory leaks #11578

Merged
merged 3 commits into from
Feb 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ constexpr u32 WIDTH_PER_BRANCH_ARROW = 16;
class BranchDisplayDelegate : public QStyledItemDelegate
{
public:
BranchDisplayDelegate(CodeViewWidget* parent) : m_parent(parent) {}
BranchDisplayDelegate(CodeViewWidget* parent) : QStyledItemDelegate(parent), m_parent(parent) {}

private:
CodeViewWidget* m_parent;
Expand Down
34 changes: 17 additions & 17 deletions Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,36 +321,36 @@ void MemoryViewWidget::CreateTable()

// Create cells and add data that won't be changing.
// Breakpoint buttons
auto* bp_item = new QTableWidgetItem;
bp_item->setFlags(Qt::ItemIsEnabled);
bp_item->setData(USER_ROLE_IS_ROW_BREAKPOINT_CELL, true);
bp_item->setData(USER_ROLE_VALUE_TYPE, static_cast<int>(Type::Null));
auto bp_item = QTableWidgetItem();
bp_item.setFlags(Qt::ItemIsEnabled);
bp_item.setData(USER_ROLE_IS_ROW_BREAKPOINT_CELL, true);
bp_item.setData(USER_ROLE_VALUE_TYPE, static_cast<int>(Type::Null));

// Row Addresses
auto* row_item = new QTableWidgetItem(INVALID_MEMORY);
row_item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
row_item->setData(USER_ROLE_IS_ROW_BREAKPOINT_CELL, false);
row_item->setData(USER_ROLE_VALUE_TYPE, static_cast<int>(Type::Null));
auto row_item = QTableWidgetItem(INVALID_MEMORY);
row_item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
row_item.setData(USER_ROLE_IS_ROW_BREAKPOINT_CELL, false);
row_item.setData(USER_ROLE_VALUE_TYPE, static_cast<int>(Type::Null));

// Data item
auto* item = new QTableWidgetItem(INVALID_MEMORY);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
item->setData(USER_ROLE_IS_ROW_BREAKPOINT_CELL, false);
auto item = QTableWidgetItem(INVALID_MEMORY);
item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable);
item.setData(USER_ROLE_IS_ROW_BREAKPOINT_CELL, false);

for (int i = 0; i < rows; i++)
{
m_table->setItem(i, 0, bp_item->clone());
m_table->setItem(i, 1, row_item->clone());
m_table->setItem(i, 0, bp_item.clone());
m_table->setItem(i, 1, row_item.clone());

for (int c = 0; c < m_data_columns; c++)
{
if (left_type && c < data_span)
{
item->setData(USER_ROLE_VALUE_TYPE, static_cast<int>(left_type.value()));
item.setData(USER_ROLE_VALUE_TYPE, static_cast<int>(left_type.value()));
}
else
{
item->setData(USER_ROLE_VALUE_TYPE, static_cast<int>(m_type));
item.setData(USER_ROLE_VALUE_TYPE, static_cast<int>(m_type));

// Left type will never be these.
auto text_alignment = Qt::AlignLeft;
Expand All @@ -359,10 +359,10 @@ void MemoryViewWidget::CreateTable()
{
text_alignment = Qt::AlignRight;
}
item->setTextAlignment(text_alignment | Qt::AlignVCenter);
item.setTextAlignment(text_alignment | Qt::AlignVCenter);
}

m_table->setItem(i, c + MISC_COLUMNS, item->clone());
m_table->setItem(i, c + MISC_COLUMNS, item.clone());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class HotkeySuppressions
void operator()(T* func)
{
(*func)();
delete func;
}
};

Expand Down