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();
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "util/QObjectRef.hpp"
|
||||
#include "widgets/BaseWidget.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QPaintEvent>
|
||||
#include <QPointer>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
@@ -113,8 +113,8 @@ protected:
|
||||
|
||||
Split *const split_;
|
||||
ChannelView *const channelView_;
|
||||
QObjectRef<EmotePopup> emotePopup_;
|
||||
QObjectRef<InputCompletionPopup> inputCompletionPopup_;
|
||||
QPointer<EmotePopup> emotePopup_;
|
||||
QPointer<InputCompletionPopup> inputCompletionPopup_;
|
||||
|
||||
struct {
|
||||
ResizingTextEdit *textEdit;
|
||||
|
||||
Reference in New Issue
Block a user