From d5b1768d70f1f6243bd1db8c2caecbc9192de011 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Sun, 24 Nov 2019 14:57:57 +0900 Subject: [PATCH] reimplement Q_DISABLE_COPY_MOVE for full compatibility with versions < 5.13 I was under the impression Q_DISABLE_COPY_MOVE was a much older function than it is. Since we historically target 5.6 and these functions are small convenience functions, I just implemented them in the actual codebase. --- app/common/constructors.h | 20 +++++++++++++++++++ app/decoder/decoder.h | 4 ++-- app/decoder/waveinput.h | 3 ++- app/decoder/waveoutput.h | 3 ++- app/render/backend/opengl/openglframebuffer.h | 3 ++- app/render/backend/opengl/opengltexture.h | 3 ++- app/render/backend/renderbackend.h | 3 ++- app/render/backend/renderworker.h | 3 ++- 8 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 app/common/constructors.h diff --git a/app/common/constructors.h b/app/common/constructors.h new file mode 100644 index 000000000..1e0dcbc4a --- /dev/null +++ b/app/common/constructors.h @@ -0,0 +1,20 @@ +#ifndef CONSTRUCTORS_H +#define CONSTRUCTORS_H + +/** + * Copy/move deleters. Similar to Q_DISABLE_COPY_MOVE, et al. but those functions + */ + +#define DISABLE_COPY(Class) \ + Class(const Class &) = delete;\ + Class &operator=(const Class &) = delete; + +#define DISABLE_MOVE(Class) \ + Class(Class &&) = delete; \ + Class &operator=(Class &&) = delete; + +#define DISABLE_COPY_MOVE(Class) \ + DISABLE_COPY(Class) \ + DISABLE_MOVE(Class) + +#endif // CONSTRUCTORS_H diff --git a/app/decoder/decoder.h b/app/decoder/decoder.h index 005283027..3b810585e 100644 --- a/app/decoder/decoder.h +++ b/app/decoder/decoder.h @@ -22,9 +22,9 @@ #define DECODER_H #include -#include #include +#include "common/constructors.h" #include "common/rational.h" #include "project/item/footage/footage.h" #include "decoder/frame.h" @@ -59,7 +59,7 @@ public: // Necessary for subclassing, it's empty virtual ~Decoder(); - Q_DISABLE_COPY_MOVE(Decoder) + DISABLE_COPY_MOVE(Decoder) virtual QString id() = 0; diff --git a/app/decoder/waveinput.h b/app/decoder/waveinput.h index 849afd135..d23e43e80 100644 --- a/app/decoder/waveinput.h +++ b/app/decoder/waveinput.h @@ -3,6 +3,7 @@ #include +#include "common/constructors.h" #include "render/audioparams.h" class WaveInput @@ -12,7 +13,7 @@ public: ~WaveInput(); - Q_DISABLE_COPY_MOVE(WaveInput) + DISABLE_COPY_MOVE(WaveInput) bool open(); diff --git a/app/decoder/waveoutput.h b/app/decoder/waveoutput.h index 8f8d8ccb2..016ce6dc5 100644 --- a/app/decoder/waveoutput.h +++ b/app/decoder/waveoutput.h @@ -5,6 +5,7 @@ #include #include "audio/sampleformat.h" +#include "common/constructors.h" #include "render/audioparams.h" class WaveOutput @@ -15,7 +16,7 @@ public: ~WaveOutput(); - Q_DISABLE_COPY_MOVE(WaveOutput) + DISABLE_COPY_MOVE(WaveOutput) bool open(); diff --git a/app/render/backend/opengl/openglframebuffer.h b/app/render/backend/opengl/openglframebuffer.h index 94a909ad0..ad063e48d 100644 --- a/app/render/backend/opengl/openglframebuffer.h +++ b/app/render/backend/opengl/openglframebuffer.h @@ -23,6 +23,7 @@ #include +#include "common/constructors.h" #include "opengltexture.h" class OpenGLFramebuffer : public QObject @@ -32,7 +33,7 @@ public: OpenGLFramebuffer(); virtual ~OpenGLFramebuffer() override; - Q_DISABLE_COPY_MOVE(OpenGLFramebuffer) + DISABLE_COPY_MOVE(OpenGLFramebuffer) void Create(QOpenGLContext *ctx); diff --git a/app/render/backend/opengl/opengltexture.h b/app/render/backend/opengl/opengltexture.h index 3c7cfca9f..ba8abe612 100644 --- a/app/render/backend/opengl/opengltexture.h +++ b/app/render/backend/opengl/opengltexture.h @@ -24,6 +24,7 @@ #include #include +#include "common/constructors.h" #include "decoder/frame.h" #include "render/pixelformat.h" @@ -42,7 +43,7 @@ public: OpenGLTexture(); virtual ~OpenGLTexture() override; - Q_DISABLE_COPY_MOVE(OpenGLTexture) + DISABLE_COPY_MOVE(OpenGLTexture) void Create(QOpenGLContext* ctx, int width, int height, const olive::PixelFormat &format, void *data = nullptr); void Create(QOpenGLContext* ctx, int width, int height, const olive::PixelFormat &format, const Type& type, void *data = nullptr); diff --git a/app/render/backend/renderbackend.h b/app/render/backend/renderbackend.h index 405ec3e9b..50eb5aa80 100644 --- a/app/render/backend/renderbackend.h +++ b/app/render/backend/renderbackend.h @@ -3,6 +3,7 @@ #include +#include "common/constructors.h" #include "decodercache.h" #include "node/graph.h" #include "node/output/viewer/viewer.h" @@ -14,7 +15,7 @@ class RenderBackend : public QObject public: RenderBackend(QObject* parent = nullptr); - Q_DISABLE_COPY_MOVE(RenderBackend) + DISABLE_COPY_MOVE(RenderBackend) bool Init(); diff --git a/app/render/backend/renderworker.h b/app/render/backend/renderworker.h index 7865ecc68..6760095b8 100644 --- a/app/render/backend/renderworker.h +++ b/app/render/backend/renderworker.h @@ -3,6 +3,7 @@ #include +#include "common/constructors.h" #include "node/block/block.h" #include "node/node.h" #include "decodercache.h" @@ -13,7 +14,7 @@ class RenderWorker : public QObject public: RenderWorker(DecoderCache* decoder_cache, QObject* parent = nullptr); - Q_DISABLE_COPY_MOVE(RenderWorker) + DISABLE_COPY_MOVE(RenderWorker) bool Init();