From 285c4b95df54b1a31dc21596c38daf484280ce6a Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 28 Aug 2020 13:01:19 +0100 Subject: [PATCH] Add Qt5Qml.dll stub for 32-bit pyside2 distribution * When the pyside2 we ship was built it accidentally included a small dependency on Qt5Qml, which we don't distribute so the pyside2 libraries wouldn't load. * We can generate a tiny stub with the right exports and load it manually from the PySide2 folder on 32-bit qrenderdoc builds to allow pyside2 to load subsequently. The stub source is tiny, and added alongside. * Putting it in the PySide2 folder means that even if someone puts RenderDoc's build folder in their PATH, our stub Qt5Qml won't break anything because it won't be loaded. If they put PySide2 in the PATH it might, but then it's their fault! --- .../3rdparty/pyside/Win32/PySide2/Qt5Qml.dll | Bin 0 -> 2048 bytes .../pyside/Win32/PySide2/Qt5Qml_stub.cpp | 24 ++++++++++++++++++ qrenderdoc/Code/pyrenderdoc/PythonContext.cpp | 13 ++++++++++ qrenderdoc/qrenderdoc_local.vcxproj | 5 ++++ 4 files changed, 42 insertions(+) create mode 100644 qrenderdoc/3rdparty/pyside/Win32/PySide2/Qt5Qml.dll create mode 100644 qrenderdoc/3rdparty/pyside/Win32/PySide2/Qt5Qml_stub.cpp diff --git a/qrenderdoc/3rdparty/pyside/Win32/PySide2/Qt5Qml.dll b/qrenderdoc/3rdparty/pyside/Win32/PySide2/Qt5Qml.dll new file mode 100644 index 0000000000000000000000000000000000000000..31da57981a4085f7e1ef78d98a09bbd1cd0aac62 GIT binary patch literal 2048 zcmeHIPiqrF6n}|PNNYj_Jv)&cJOypcMG8(dp^?Tm$)-7!K-^@9?P{_cHxrr$ym?l^ ziyuHds0RfP!BeO=u@}XoAbtT61TR8;Z+6#)79O>B@tKr_l#oWr(eb4WppPw4wZJ2wGFG!dah%-dY83z+jb;t3FZ!LX4x#isI`hJqB;R&`M-^}q!OtN4<_UZ;w3iVz^wswHup19h!tdEP41mgu zev0rA^=F6)Le)0bcVY@3(EbBa#Pi)oj1ja$7$;Z+Dl%K?cG5QV81uqM?Z}p|HWnJ$KgeDzVHwCZMFL>!|g`sE< zq~+Lt!U8Yn)>JHC;IxpCvqAFFn$e|Z1yjd8`reKz)g*U6H?w(VQnq8^U PXk@fZm3YYh)eZavsNMQH literal 0 HcmV?d00001 diff --git a/qrenderdoc/3rdparty/pyside/Win32/PySide2/Qt5Qml_stub.cpp b/qrenderdoc/3rdparty/pyside/Win32/PySide2/Qt5Qml_stub.cpp new file mode 100644 index 000000000..340c17743 --- /dev/null +++ b/qrenderdoc/3rdparty/pyside/Win32/PySide2/Qt5Qml_stub.cpp @@ -0,0 +1,24 @@ +typedef unsigned long DWORD; +typedef void *HANDLE; +typedef void *LPVOID; + +class QObject; +class QString; + +class QQmlData { +public: __declspec(dllexport) static class QQmlData *__cdecl get(const QObject*,bool) {return 0;} +}; + +namespace QV4 { +struct Value; +struct ExecutionEngine { + __declspec(dllexport) unsigned __int64 __thiscall throwError(const QString&) {return 0;} + __declspec(dllexport) unsigned __int64 __thiscall throwSyntaxError(const QString&) {return 0;} + __declspec(dllexport) unsigned __int64 __thiscall throwTypeError(const QString&) {return 0;} +}; +struct PersistentValueStorage { + __declspec(dllexport) static ExecutionEngine *__cdecl getEngine(Value*) {return 0;} +}; +}; + +extern "C" long __stdcall _DllMainCRTStartup(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) {return 1;} \ No newline at end of file diff --git a/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp b/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp index c8369ce24..fd5548c54 100644 --- a/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp +++ b/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp @@ -56,6 +56,11 @@ PyTypeObject **SbkPySide2_QtWidgetsTypes = NULL; #endif +#ifdef _MSC_VER +// for the LoadLibrary call on 32-bit windows +#include +#endif + #include #include #include @@ -342,6 +347,14 @@ void PythonContext::GlobalInit() // set up PySide #if PYSIDE2_ENABLED { +// hack for win32 builds, where our pyside2 accidentally depends on Qt5Qml.dll for no good +// reason and we ship a stub to allow the dll to load instead of rebuilding the whole of pyside2 +// :S +#if defined(_MSC_VER) && !defined(_M_X64) + QString Qt5QmlStub = QApplication::applicationDirPath() + lit("/PySide2/Qt5Qml.dll"); + LoadLibraryA(Qt5QmlStub.toUtf8().data()); +#endif + Shiboken::AutoDecRef core(Shiboken::Module::import("PySide2.QtCore")); if(!core.isNull()) SbkPySide2_QtCoreTypes = Shiboken::Module::getTypes(core); diff --git a/qrenderdoc/qrenderdoc_local.vcxproj b/qrenderdoc/qrenderdoc_local.vcxproj index d92f2f30d..1651661f4 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj +++ b/qrenderdoc/qrenderdoc_local.vcxproj @@ -1712,6 +1712,11 @@ IF %ERRORLEVEL% NEQ 0 (echo ==================================================== PreserveNewest false + + PySide2\Qt5Qml.dll + PreserveNewest + false + PySide2\__init__.py PreserveNewest