]> git.lyx.org Git - features.git/commitdiff
Re-enable QWindowsMimeMetafile with Qt6
authorEnrico Forestieri <forenr@lyx.org>
Fri, 28 Apr 2023 21:34:01 +0000 (23:34 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Fri, 28 Apr 2023 21:34:01 +0000 (23:34 +0200)
Qt 6.5.0 has dropped support for the QWindowsMime class
in favor of a new QWindowsMimeConverter class. They say:
  "If you have implementations of QWindowsMime or QMacMime in Qt 5,
   then those will almost directly translate to the new APIs but
   require less boiler-plate code to register the converters with Qt."
This may be true, but in practice they break binary compatibility with
previous versions. If you used the QWindowsMime class until Qt 6.4 by
using boiler-plate code to register the converters with Qt, you now
need to modify the sources and recompile. Fantastic!

src/frontends/qt/GuiApplication.cpp

index 0fd63a37c8b09b1402606a3fa19fc7c3ef4ee3bf..1b29eec412a5fff4f2e57386c5464568959f822c 100644 (file)
 #if (QT_VERSION >= 0x050400)
 #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
 #if (QT_VERSION >= 0x060000)
+#if (QT_VERSION >= 0x060500)
+#include <QtGui/QWindowsMimeConverter>
+#define QWINDOWSMIME QWindowsMimeConverter
+#define QVARIANTTYPE QMetaType
+#else
 #include <QtGui/private/qguiapplication_p.h>
 #include <QtGui/private/qwindowsmime_p.h>
 #include <QtGui/qpa/qplatformintegration.h>
 #define QVARIANTTYPE QMetaType
 using QWindowsMime = QNativeInterface::Private::QWindowsMime;
 using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
+#endif
 #else
 #include <QWinMime>
 #define QWINDOWSMIME QWinMime
@@ -1031,7 +1037,7 @@ struct GuiApplication::Private
        #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
                /// WMF Mime handler for Windows clipboard.
                wmf_mime_ = new QWindowsMimeMetafile;
-       #if (QT_VERSION >= 0x060000)
+       #if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500)
                win_app_ = dynamic_cast<QWindowsApplication *>
                        (QGuiApplicationPrivate::platformIntegration());
                win_app_->registerMime(wmf_mime_);
@@ -1041,7 +1047,7 @@ struct GuiApplication::Private
                initKeySequences(&theTopLevelKeymap());
        }
 
-       #if (QT_VERSION >= 0x060000)
+       #if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500)
        #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
        ~Private()
        {
@@ -1120,7 +1126,7 @@ struct GuiApplication::Private
 #if defined(Q_OS_WIN) || defined(Q_CYGWIN_WIN)
        /// WMF Mime handler for Windows clipboard.
        QWindowsMimeMetafile * wmf_mime_;
-#if (QT_VERSION >= 0x060000)
+#if (QT_VERSION >= 0x060000 && QT_VERSION < 0x060500)
        QWindowsApplication * win_app_;
 #endif
 #endif