Add a parent to SplitInput's QCompleter

mini memory leak fix
This commit is contained in:
Rasmus Karlsson 2023-12-03 12:58:11 +01:00
parent fbf13c7a9e
commit 295b38a8f1
2 changed files with 7 additions and 4 deletions

View file

@ -50,13 +50,13 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
this->installEventFilter(this); this->installEventFilter(this);
this->initLayout(); this->initLayout();
auto completer = auto *completer =
new QCompleter(&this->split_->getChannel()->completionModel); new QCompleter(&this->split_->getChannel()->completionModel, this);
this->ui_.textEdit->setCompleter(completer); this->ui_.textEdit->setCompleter(completer);
this->signalHolder_.managedConnect(this->split_->channelChanged, [this] { this->signalHolder_.managedConnect(this->split_->channelChanged, [this] {
auto channel = this->split_->getChannel(); auto channel = this->split_->getChannel();
auto completer = new QCompleter(&channel->completionModel); auto *completer = new QCompleter(&channel->completionModel, this);
this->ui_.textEdit->setCompleter(completer); this->ui_.textEdit->setCompleter(completer);
}); });
@ -76,6 +76,8 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
}); });
} }
SplitInput::~SplitInput() = default;
void SplitInput::initLayout() void SplitInput::initLayout()
{ {
auto app = getApp(); auto app = getApp();

View file

@ -24,7 +24,7 @@ class ResizingTextEdit;
class ChannelView; class ChannelView;
enum class CompletionKind; enum class CompletionKind;
class SplitInput : public BaseWidget class SplitInput final : public BaseWidget
{ {
Q_OBJECT Q_OBJECT
@ -32,6 +32,7 @@ public:
SplitInput(Split *_chatWidget, bool enableInlineReplying = true); SplitInput(Split *_chatWidget, bool enableInlineReplying = true);
SplitInput(QWidget *parent, Split *_chatWidget, ChannelView *_channelView, SplitInput(QWidget *parent, Split *_chatWidget, ChannelView *_channelView,
bool enableInlineReplying = true); bool enableInlineReplying = true);
~SplitInput() override;
bool hasSelection() const; bool hasSelection() const;
void clearSelection() const; void clearSelection() const;