Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove boost::noncopyable use & boost::random dependency #4776

Merged
merged 18 commits into from
Sep 9, 2023
Merged
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Checks: "-*,
-performance-noexcept-move-constructor,
-misc-non-private-member-variables-in-classes,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-special-member-functions,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-readability-identifier-length,
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Dev: Temporarily disable High DPI scaling on Qt6 builds on Windows. (#4767)
- Dev: Tests now run on Ubuntu 22.04 instead of 20.04 to loosen C++ restrictions in tests. (#4774)
- Dev: Do a pretty major refactor of the Settings classes. List settings (e.g. highlights) are most heavily modified, and should have an extra eye kept on them. (#4775)
- Dev: Remove `boost::noncopyable` use & `boost_random` dependency. (#4776)

## 2.4.5

Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ endif ()
find_package(Sanitizers QUIET)

# Find boost on the system
# `OPTIONAL_COMPONENTS random` is required for vcpkg builds to link.
# `OPTIONAL` is required, because conan doesn't set `boost_random_FOUND`.
find_package(Boost REQUIRED OPTIONAL_COMPONENTS random)
find_package(Boost REQUIRED OPTIONAL_COMPONENTS headers)

# Find OpenSSL on the system
find_package(OpenSSL REQUIRED)
Expand Down
1 change: 0 additions & 1 deletion src/PrecompiledHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# include <boost/circular_buffer.hpp>
# include <boost/current_function.hpp>
# include <boost/foreach.hpp>
# include <boost/noncopyable.hpp>
# include <boost/optional.hpp>
# include <boost/signals2.hpp>
# include <IrcCommand>
Expand Down
14 changes: 8 additions & 6 deletions src/common/Atomic.hpp
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
#pragma once

#include <boost/noncopyable.hpp>

#include <mutex>

namespace chatterino {

template <typename T>
class Atomic : boost::noncopyable
class Atomic
pajlada marked this conversation as resolved.
Show resolved Hide resolved
{
public:
Atomic()
{
}
Atomic() = default;

Atomic(T &&val)
: value_(val)
{
}

Atomic(const Atomic &) = delete;
Atomic &operator=(const Atomic &) = delete;

Atomic(Atomic &&) = delete;
Atomic &operator=(Atomic &&) = delete;

T get() const
{
std::lock_guard<std::mutex> guard(this->mutex_);
Expand Down
9 changes: 7 additions & 2 deletions src/common/SignalVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "debug/AssertInGuiThread.hpp"

#include <boost/noncopyable.hpp>
#include <pajlada/signals/signal.hpp>
#include <QStandardItemModel>
#include <QTimer>
Expand All @@ -19,7 +18,7 @@ struct SignalVectorItemEvent {
};

template <typename T>
class SignalVector : boost::noncopyable
class SignalVector
pajlada marked this conversation as resolved.
Show resolved Hide resolved
{
public:
pajlada::Signals::Signal<SignalVectorItemEvent<T>> itemInserted;
Expand All @@ -42,6 +41,12 @@ class SignalVector : boost::noncopyable
this->itemCompare_ = std::move(compare);
}

SignalVector(const SignalVector &) = delete;
SignalVector &operator=(const SignalVector &) = delete;

SignalVector(SignalVector &&) = delete;
SignalVector &operator=(SignalVector &&) = delete;

bool isSorted() const
{
return bool(this->itemCompare_);
Expand Down
11 changes: 8 additions & 3 deletions src/common/Singleton.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
#pragma once

#include <boost/noncopyable.hpp>

namespace chatterino {

class Settings;
class Paths;

class Singleton : boost::noncopyable
class Singleton
{
public:
Singleton() = default;
virtual ~Singleton() = default;

Singleton(const Singleton &) = delete;
Singleton &operator=(const Singleton &) = delete;

Singleton(Singleton &&) = delete;
Singleton &operator=(Singleton &&) = delete;

virtual void initialize(Settings &settings, Paths &paths)
{
(void)(settings);
Expand Down
10 changes: 8 additions & 2 deletions src/debug/Benchmark.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
#pragma once

#include <boost/noncopyable.hpp>
#include <QElapsedTimer>
#include <QString>

namespace chatterino {

class BenchmarkGuard : boost::noncopyable
class BenchmarkGuard
{
public:
BenchmarkGuard(const QString &_name);
~BenchmarkGuard();

BenchmarkGuard(const BenchmarkGuard &) = delete;
BenchmarkGuard &operator=(const BenchmarkGuard &) = delete;

BenchmarkGuard(BenchmarkGuard &&) = delete;
BenchmarkGuard &operator=(BenchmarkGuard &&) = delete;

qreal getElapsedMs();

private:
Expand Down
17 changes: 14 additions & 3 deletions src/messages/Image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "common/Aliases.hpp"
#include "common/Common.hpp"

#include <boost/noncopyable.hpp>
#include <boost/optional.hpp>
#include <boost/variant.hpp>
#include <pajlada/signals/signal.hpp>
Expand All @@ -26,13 +25,19 @@ namespace detail {
Image image;
int duration;
};
class Frames : boost::noncopyable
class Frames
{
public:
Frames();
Frames(QVector<Frame<QPixmap>> &&frames);
~Frames();

Frames(const Frames &) = delete;
Frames &operator=(const Frames &) = delete;

Frames(Frames &&) = delete;
Frames &operator=(Frames &&) = delete;

void clear();
bool empty() const;
bool animated() const;
Expand All @@ -54,14 +59,20 @@ class Image;
using ImagePtr = std::shared_ptr<Image>;

/// This class is thread safe.
class Image : public std::enable_shared_from_this<Image>, boost::noncopyable
class Image : public std::enable_shared_from_this<Image>
{
public:
// Maximum amount of RAM used by the image in bytes.
static constexpr int maxBytesRam = 20 * 1024 * 1024;

~Image();

Image(const Image &) = delete;
Image &operator=(const Image &) = delete;

Image(Image &&) = delete;
Image &operator=(Image &&) = delete;

static ImagePtr fromUrl(const Url &url, qreal scale = 1);
static ImagePtr fromResourcePixmap(const QPixmap &pixmap, qreal scale = 1);
static ImagePtr getEmpty();
Expand Down
9 changes: 7 additions & 2 deletions src/messages/Message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "common/FlagsEnum.hpp"
#include "util/QStringHash.hpp"

#include <boost/noncopyable.hpp>
#include <QColor>
#include <QTime>

Expand Down Expand Up @@ -54,10 +53,16 @@ enum class MessageFlag : int64_t {
};
using MessageFlags = FlagsEnum<MessageFlag>;

struct Message : boost::noncopyable {
struct Message {
Message();
~Message();

Message(const Message &) = delete;
Message &operator=(const Message &) = delete;

Message(Message &&) = delete;
Message &operator=(Message &&) = delete;

// Making this a mutable means that we can update a messages flags,
// while still keeping Message constant. This means that a message's flag
// can be updated without the renderer being made aware, which might be bad.
Expand Down
9 changes: 7 additions & 2 deletions src/messages/MessageElement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "messages/MessageColor.hpp"
#include "singletons/Fonts.hpp"

#include <boost/noncopyable.hpp>
#include <pajlada/signals/signalholder.hpp>
#include <QRect>
#include <QString>
Expand Down Expand Up @@ -158,7 +157,7 @@ enum class MessageElementFlag : int64_t {
};
using MessageElementFlags = FlagsEnum<MessageElementFlag>;

class MessageElement : boost::noncopyable
class MessageElement
{
public:
enum UpdateFlags : char {
Expand All @@ -173,6 +172,12 @@ class MessageElement : boost::noncopyable

virtual ~MessageElement();

MessageElement(const MessageElement &) = delete;
MessageElement &operator=(const MessageElement &) = delete;

MessageElement(MessageElement &&) = delete;
MessageElement &operator=(MessageElement &&) = delete;

MessageElement *setLink(const Link &link);
MessageElement *setText(const QString &text);
MessageElement *setTooltip(const QString &tooltip);
Expand Down
9 changes: 7 additions & 2 deletions src/messages/layouts/MessageLayout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "common/FlagsEnum.hpp"
#include "messages/layouts/MessageLayoutContainer.hpp"

#include <boost/noncopyable.hpp>
#include <QPixmap>

#include <cinttypes>
Expand Down Expand Up @@ -33,12 +32,18 @@ enum class MessageLayoutFlag : uint8_t {
};
using MessageLayoutFlags = FlagsEnum<MessageLayoutFlag>;

class MessageLayout : boost::noncopyable
class MessageLayout
{
public:
MessageLayout(MessagePtr message_);
~MessageLayout();

MessageLayout(const MessageLayout &) = delete;
MessageLayout &operator=(const MessageLayout &) = delete;

MessageLayout(MessageLayout &&) = delete;
MessageLayout &operator=(MessageLayout &&) = delete;

const Message *getMessage();
const MessagePtr &getMessagePtr() const;

Expand Down
9 changes: 7 additions & 2 deletions src/messages/layouts/MessageLayoutElement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "common/FlagsEnum.hpp"
#include "messages/Link.hpp"

#include <boost/noncopyable.hpp>
#include <pajlada/signals/signalholder.hpp>
#include <QPen>
#include <QPoint>
Expand All @@ -23,12 +22,18 @@ enum class FontStyle : uint8_t;
enum class MessageElementFlag : int64_t;
struct MessageColors;

class MessageLayoutElement : boost::noncopyable
class MessageLayoutElement
{
public:
MessageLayoutElement(MessageElement &creator_, const QSize &size);
virtual ~MessageLayoutElement();

MessageLayoutElement(const MessageLayoutElement &) = delete;
MessageLayoutElement &operator=(const MessageLayoutElement &) = delete;

MessageLayoutElement(MessageLayoutElement &&) = delete;
MessageLayoutElement &operator=(MessageLayoutElement &&) = delete;

bool reversedNeutral = false;

const QRect &getRect() const;
Expand Down
11 changes: 9 additions & 2 deletions src/providers/IvrApi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "common/NetworkRequest.hpp"
#include "providers/twitch/TwitchEmotes.hpp"

#include <boost/noncopyable.hpp>
#include <QJsonArray>
#include <QJsonObject>

Expand Down Expand Up @@ -74,7 +73,7 @@ struct IvrEmote {
}
};

class IvrApi final : boost::noncopyable
class IvrApi final
pajlada marked this conversation as resolved.
Show resolved Hide resolved
{
public:
// https://api.ivr.fi/v2/docs/static/index.html#/Twitch/get_twitch_subage__user___channel_
Expand All @@ -89,6 +88,14 @@ class IvrApi final : boost::noncopyable

static void initialize();

IvrApi() = default;

IvrApi(const IvrApi &) = delete;
IvrApi &operator=(const IvrApi &) = delete;

IvrApi(IvrApi &&) = delete;
IvrApi &operator=(IvrApi &&) = delete;

private:
NetworkRequest makeRequest(QString url, QUrlQuery urlQuery);
};
Expand Down
1 change: 0 additions & 1 deletion src/singletons/Fonts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "common/ChatterinoSetting.hpp"
#include "common/Singleton.hpp"

#include <boost/noncopyable.hpp>
#include <pajlada/signals/signal.hpp>
#include <QFont>
#include <QFontDatabase>
Expand Down
10 changes: 8 additions & 2 deletions src/singletons/helper/LoggingChannel.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <boost/noncopyable.hpp>
#include <QDateTime>
#include <QFile>
#include <QString>
Expand All @@ -13,13 +12,20 @@ class Logging;
struct Message;
using MessagePtr = std::shared_ptr<const Message>;

class LoggingChannel : boost::noncopyable
class LoggingChannel
{
explicit LoggingChannel(const QString &_channelName,
const QString &platform);

public:
~LoggingChannel();

LoggingChannel(const LoggingChannel &) = delete;
LoggingChannel &operator=(const LoggingChannel &) = delete;

LoggingChannel(LoggingChannel &&) = delete;
LoggingChannel &operator=(LoggingChannel &&) = delete;

void addMessage(MessagePtr message);

private:
Expand Down
1 change: 0 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"boost-circular-buffer",
"boost-foreach",
"boost-interprocess",
"boost-random",
"boost-signals2",
"boost-variant",
"gtest",
Expand Down