Skip to content

Commit

Permalink
Add a parent to SplitInput's QCompleter
Browse files Browse the repository at this point in the history
mini memory leak fix
  • Loading branch information
pajlada committed Dec 3, 2023
1 parent fbf13c7 commit 295b38a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/widgets/splits/SplitInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
this->installEventFilter(this);
this->initLayout();

auto completer =
new QCompleter(&this->split_->getChannel()->completionModel);
auto *completer =
new QCompleter(&this->split_->getChannel()->completionModel, this);
this->ui_.textEdit->setCompleter(completer);

this->signalHolder_.managedConnect(this->split_->channelChanged, [this] {
auto channel = this->split_->getChannel();
auto completer = new QCompleter(&channel->completionModel);
auto *completer = new QCompleter(&channel->completionModel, this);
this->ui_.textEdit->setCompleter(completer);
});

Expand All @@ -76,6 +76,8 @@ SplitInput::SplitInput(QWidget *parent, Split *_chatWidget,
});
}

SplitInput::~SplitInput() = default;

void SplitInput::initLayout()
{
auto app = getApp();
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/splits/SplitInput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ class ResizingTextEdit;
class ChannelView;
enum class CompletionKind;

class SplitInput : public BaseWidget
class SplitInput final : public BaseWidget
{
Q_OBJECT

public:
SplitInput(Split *_chatWidget, bool enableInlineReplying = true);
SplitInput(QWidget *parent, Split *_chatWidget, ChannelView *_channelView,
bool enableInlineReplying = true);
~SplitInput() override;

bool hasSelection() const;
void clearSelection() const;
Expand Down

0 comments on commit 295b38a

Please sign in to comment.