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 SplitterStyle destruction causing memory leak #743

Merged
merged 1 commit into from
Feb 9, 2025
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
2 changes: 1 addition & 1 deletion src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ void MainWindow::setupMainWindow()
#endif
ui->listviewLabel1->setFont(titleFont);
ui->listviewLabel2->setFont(titleFont);
m_splitterStyle = new SplitterStyle();
m_splitterStyle = new SplitterStyle(this);
m_splitter->setStyle(m_splitterStyle);
m_splitter->setHandleWidth(0);
setNoteListLoading();
Expand Down
5 changes: 4 additions & 1 deletion src/splitterstyle.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include "splitterstyle.h"

SplitterStyle::SplitterStyle() { }
SplitterStyle::SplitterStyle(QObject *parent) : QProxyStyle()
{
setParent(parent); // to ensure proper object destruction
}

void SplitterStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
const QWidget *w) const
Expand Down
8 changes: 4 additions & 4 deletions src/splitterstyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

class SplitterStyle : public QProxyStyle
{
Q_OBJECT
public:
SplitterStyle();
SplitterStyle(QObject *parent);

// QStyle interface
public:
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
const QWidget *w) const override;
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
const QWidget *w) const override;
};

#endif // SPLITTERSTYLE_H