소스 검색

frontend: Fix visibility issues of meta type stream operators

For custom types to become usable as QVariants they not only need to
be declared as meta types, but also need to have appropriate stream
operators declared.

These declarations (both of the meta type itself, which provides a
static meta type ID getter via the macro, as well as the operators)
need to be visible to the compiler in any compilation unit where they
might be used in their QVariant form, otherwise the templates will
be incomplete.

A blanket include of "qt-wrappers.hpp" in "OBSBasic.hpp" is not the
most subtle fix, but it's necessary to ensure that the meta types
are always "complete". Putting both declarations in the qt-wrappers
header (instead of splitting them up) ensures that (as the classes
themselves are declared in "obs.hpp", which is included by
"qt-wrappers.hpp", and thus qt-wrappers can provide a complete class.
PatTheMav 4 달 전
부모
커밋
059fd6210c
2개의 변경된 파일5개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 4
      frontend/widgets/OBSBasic.hpp
  2. 4 0
      shared/qt/wrappers/qt-wrappers.hpp

+ 1 - 4
frontend/widgets/OBSBasic.hpp

@@ -30,10 +30,7 @@
 
 #include <obs-frontend-internal.hpp>
 #include <obs.hpp>
-
-Q_DECLARE_METATYPE(OBSScene);
-Q_DECLARE_METATYPE(OBSSceneItem);
-Q_DECLARE_METATYPE(OBSSource);
+#include <qt-wrappers.hpp>
 
 #include <graphics/matrix4.h>
 #include <util/platform.h>

+ 4 - 0
shared/qt/wrappers/qt-wrappers.hpp

@@ -63,6 +63,10 @@ QDataStream &operator>>(QDataStream &in, OBSScene &scene);
 QDataStream &operator<<(QDataStream &out, const OBSSource &source);
 QDataStream &operator>>(QDataStream &in, OBSSource &source);
 
+Q_DECLARE_METATYPE(OBSScene);
+Q_DECLARE_METATYPE(OBSSceneItem);
+Q_DECLARE_METATYPE(OBSSource);
+
 QThread *CreateQThread(std::function<void()> func);
 
 void ExecuteFuncSafeBlock(std::function<void()> func);