mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
refactor: Remove the NullablePtr
class (#5091)
This commit is contained in:
parent
47a14c9041
commit
7f935665f9
|
@ -109,7 +109,7 @@
|
||||||
- Dev: Fixed deadlock and use-after-free in tests. (#4981)
|
- Dev: Fixed deadlock and use-after-free in tests. (#4981)
|
||||||
- Dev: Moved all `.clang-format` files to the root directory. (#5037)
|
- Dev: Moved all `.clang-format` files to the root directory. (#5037)
|
||||||
- Dev: Load less message history upon reconnects. (#5001, #5018)
|
- Dev: Load less message history upon reconnects. (#5001, #5018)
|
||||||
- Dev: Load less message history upon reconnects. (#5001)
|
- Dev: Removed the `NullablePtr` class. (#5091)
|
||||||
- Dev: BREAKING: Replace custom `import()` with normal Lua `require()`. (#5014)
|
- Dev: BREAKING: Replace custom `import()` with normal Lua `require()`. (#5014)
|
||||||
- Dev: Fixed most compiler warnings. (#5028)
|
- Dev: Fixed most compiler warnings. (#5028)
|
||||||
- Dev: Added the ability to show `ChannelView`s without a `Split`. (#4747)
|
- Dev: Added the ability to show `ChannelView`s without a `Split`. (#4747)
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <type_traits>
|
|
||||||
|
|
||||||
namespace chatterino {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
class NullablePtr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NullablePtr()
|
|
||||||
: element_(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NullablePtr(T *element)
|
|
||||||
: element_(element)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
T *operator->() const
|
|
||||||
{
|
|
||||||
assert(this->hasElement());
|
|
||||||
|
|
||||||
return element_;
|
|
||||||
}
|
|
||||||
|
|
||||||
typename std::add_lvalue_reference<T>::type operator*() const
|
|
||||||
{
|
|
||||||
assert(this->hasElement());
|
|
||||||
|
|
||||||
return *element_;
|
|
||||||
}
|
|
||||||
|
|
||||||
T *get() const
|
|
||||||
{
|
|
||||||
assert(this->hasElement());
|
|
||||||
|
|
||||||
return this->element_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isNull() const
|
|
||||||
{
|
|
||||||
return this->element_ == nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasElement() const
|
|
||||||
{
|
|
||||||
return this->element_ != nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
operator bool() const
|
|
||||||
{
|
|
||||||
return this->hasElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!() const
|
|
||||||
{
|
|
||||||
return !this->hasElement();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename X = T,
|
|
||||||
typename = std::enable_if_t<!std::is_const<X>::value>>
|
|
||||||
operator NullablePtr<const T>() const
|
|
||||||
{
|
|
||||||
return NullablePtr<const T>(this->element_);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T *element_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace chatterino
|
|
|
@ -911,7 +911,7 @@ void Split::insertTextToInput(const QString &text)
|
||||||
void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
||||||
std::function<void(bool)> callback)
|
std::function<void(bool)> callback)
|
||||||
{
|
{
|
||||||
if (this->selectChannelDialog_.hasElement())
|
if (!this->selectChannelDialog_.isNull())
|
||||||
{
|
{
|
||||||
this->selectChannelDialog_->raise();
|
this->selectChannelDialog_->raise();
|
||||||
|
|
||||||
|
@ -935,7 +935,6 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
|
||||||
}
|
}
|
||||||
|
|
||||||
callback(dialog->hasSeletedChannel());
|
callback(dialog->hasSeletedChannel());
|
||||||
this->selectChannelDialog_ = nullptr;
|
|
||||||
});
|
});
|
||||||
this->selectChannelDialog_ = dialog;
|
this->selectChannelDialog_ = dialog;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
|
|
||||||
#include "common/Aliases.hpp"
|
#include "common/Aliases.hpp"
|
||||||
#include "common/Channel.hpp"
|
#include "common/Channel.hpp"
|
||||||
#include "common/NullablePtr.hpp"
|
|
||||||
#include "widgets/BaseWidget.hpp"
|
#include "widgets/BaseWidget.hpp"
|
||||||
#include "widgets/splits/SplitCommon.hpp"
|
#include "widgets/splits/SplitCommon.hpp"
|
||||||
|
|
||||||
#include <boost/signals2.hpp>
|
#include <boost/signals2.hpp>
|
||||||
#include <pajlada/signals/signalholder.hpp>
|
#include <pajlada/signals/signalholder.hpp>
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QPointer>
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
@ -155,7 +155,7 @@ private:
|
||||||
SplitInput *const input_;
|
SplitInput *const input_;
|
||||||
SplitOverlay *const overlay_;
|
SplitOverlay *const overlay_;
|
||||||
|
|
||||||
NullablePtr<SelectChannelDialog> selectChannelDialog_;
|
QPointer<SelectChannelDialog> selectChannelDialog_;
|
||||||
|
|
||||||
pajlada::Signals::Connection channelIDChangedConnection_;
|
pajlada::Signals::Connection channelIDChangedConnection_;
|
||||||
pajlada::Signals::Connection usermodeChangedConnection_;
|
pajlada::Signals::Connection usermodeChangedConnection_;
|
||||||
|
|
Loading…
Reference in a new issue