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 memory leaks #325

Merged
merged 3 commits into from
Oct 22, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/adventure/adventurewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AdventureWidget::AdventureWidget(AdventureTracker &at, QWidget *const parent)
, m_adventureTracker{at}
{
m_textEdit = new QTextEdit(this);
m_textCursor = new QTextCursor(m_textEdit->document());
m_textCursor = std::make_unique<QTextCursor>(m_textEdit->document());

m_textEdit->setReadOnly(true);
m_textEdit->setOverwriteMode(true);
Expand All @@ -32,9 +32,11 @@ AdventureWidget::AdventureWidget(AdventureTracker &at, QWidget *const parent)

QTextCharFormat blockCharFormat = m_textCursor->blockCharFormat();
blockCharFormat.setForeground(settings.foregroundColor);
auto font = new QFont();
font->fromString(settings.font); // need fromString() to extract PointSize
blockCharFormat.setFont(*font);
{
QFont font;
font.fromString(settings.font); // need fromString() to extract PointSize
blockCharFormat.setFont(font);
}
m_textCursor->setBlockCharFormat(blockCharFormat);

auto layout = new QVBoxLayout(this);
Expand All @@ -45,7 +47,7 @@ AdventureWidget::AdventureWidget(AdventureTracker &at, QWidget *const parent)

addDefaultContent();

m_clearContentAction = new QAction("Clear Content");
m_clearContentAction = new QAction("Clear Content", this);
connect(m_clearContentAction,
&QAction::triggered,
this,
Expand Down
2 changes: 1 addition & 1 deletion src/adventure/adventurewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ private slots:
AdventureTracker &m_adventureTracker;

QTextEdit *m_textEdit = nullptr;
QTextCursor *m_textCursor = nullptr;
std::unique_ptr<QTextCursor> m_textCursor;
QAction *m_clearContentAction = nullptr;
};
4 changes: 2 additions & 2 deletions src/display/prespammedpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ static constexpr const bool USE_TEST = true;
static constexpr const bool USE_TEST = false;
#endif

PrespammedPath::PrespammedPath(QObject * /*unused*/)
// REVISIT: why isn't the parent passed to the base class?
PrespammedPath::PrespammedPath(QObject *parent)
: QObject(parent)
{
if (USE_TEST) {
m_queue.append(CommandEnum::DOWN);
Expand Down