Remove QObjectRef in favor of QPointer (#4666)
* replace usage of QObjectRef with QPointer * delete QObjectRef class * inlucde QPointer header * Add changelog entry * use isNull() instead of ! data() --------- Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -630,7 +630,7 @@ bool SplitInput::eventFilter(QObject *obj, QEvent *event)
|
||||
if (event->type() == QEvent::ShortcutOverride ||
|
||||
event->type() == QEvent::Shortcut)
|
||||
{
|
||||
if (auto popup = this->inputCompletionPopup_.get())
|
||||
if (auto popup = this->inputCompletionPopup_.data())
|
||||
{
|
||||
if (popup->isVisible())
|
||||
{
|
||||
@@ -650,7 +650,7 @@ void SplitInput::installKeyPressedEvent()
|
||||
{
|
||||
this->ui_.textEdit->keyPressed.disconnectAll();
|
||||
this->ui_.textEdit->keyPressed.connect([this](QKeyEvent *event) {
|
||||
if (auto *popup = this->inputCompletionPopup_.get())
|
||||
if (auto *popup = this->inputCompletionPopup_.data())
|
||||
{
|
||||
if (popup->isVisible())
|
||||
{
|
||||
@@ -764,12 +764,12 @@ void SplitInput::updateCompletionPopup()
|
||||
|
||||
void SplitInput::showCompletionPopup(const QString &text, bool emoteCompletion)
|
||||
{
|
||||
if (!this->inputCompletionPopup_.get())
|
||||
if (this->inputCompletionPopup_.isNull())
|
||||
{
|
||||
this->inputCompletionPopup_ = new InputCompletionPopup(this);
|
||||
this->inputCompletionPopup_->setInputAction(
|
||||
[that = QObjectRef(this)](const QString &text) mutable {
|
||||
if (auto *this2 = that.get())
|
||||
[that = QPointer(this)](const QString &text) mutable {
|
||||
if (auto *this2 = that.data())
|
||||
{
|
||||
this2->insertCompletionText(text);
|
||||
this2->hideCompletionPopup();
|
||||
@@ -777,7 +777,7 @@ void SplitInput::showCompletionPopup(const QString &text, bool emoteCompletion)
|
||||
});
|
||||
}
|
||||
|
||||
auto *popup = this->inputCompletionPopup_.get();
|
||||
auto *popup = this->inputCompletionPopup_.data();
|
||||
assert(popup);
|
||||
|
||||
if (emoteCompletion)
|
||||
@@ -798,7 +798,7 @@ void SplitInput::showCompletionPopup(const QString &text, bool emoteCompletion)
|
||||
|
||||
void SplitInput::hideCompletionPopup()
|
||||
{
|
||||
if (auto *popup = this->inputCompletionPopup_.get())
|
||||
if (auto *popup = this->inputCompletionPopup_.data())
|
||||
{
|
||||
popup->hide();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user