[vlc-commits] qt: main_interface: remove deprecation warning on qmlRegisterType
Alexandre Janniaux
git at videolan.org
Sat Apr 11 11:04:41 CEST 2020
vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Mon Apr 6 15:55:35 2020 +0200| [1cc58c864128acc744ffe650063016ce0c1eee8c] | committer: Alexandre Janniaux
qt: main_interface: remove deprecation warning on qmlRegisterType
qmlRegisterType is deprecated in Qt 5.14 in favour of
qmlRegisterAnonymousType which is introduced in 5.14.
The warning was spamming multiple time as it was used multiple time.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1cc58c864128acc744ffe650063016ce0c1eee8c
---
modules/gui/qt/maininterface/main_interface.cpp | 27 ++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/modules/gui/qt/maininterface/main_interface.cpp b/modules/gui/qt/maininterface/main_interface.cpp
index 8027b116cb..1d573de419 100644
--- a/modules/gui/qt/maininterface/main_interface.cpp
+++ b/modules/gui/qt/maininterface/main_interface.cpp
@@ -98,6 +98,7 @@
# include <X11/Xlib.h>
#endif
+#include <QtGlobal>
#include <QTimer>
#include <QtQml/QQmlContext>
#include <QtQuick/QQuickItem>
@@ -121,6 +122,22 @@ static int IntfRaiseMainCB( vlc_object_t *p_this, const char *psz_variable,
vlc_value_t old_val, vlc_value_t new_val,
void *param );
+namespace {
+
+template<class T>
+void registerAnonymousType( const char *uri, int versionMajor )
+{
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
+ qmlRegisterAnonymousType<T>( uri, versionMajor );
+#else
+ qmlRegisterType<T>();
+ VLC_UNUSED( uri );
+ VLC_UNUSED( versionMajor );
+#endif
+}
+
+} // anonymous namespace
+
const QEvent::Type MainInterface::ToolbarsNeedRebuild =
(QEvent::Type)QEvent::registerEventType();
@@ -357,11 +374,11 @@ void MainInterface::createMainWidget( QSettings * )
qmlRegisterType<MlFoldersModel>( "org.videolan.medialib", 0, 1, "MLFolderModel");
//expose base object, they aren't instanciable from QML side
- qmlRegisterType<MLAlbum>();
- qmlRegisterType<MLArtist>();
- qmlRegisterType<MLAlbumTrack>();
- qmlRegisterType<MLGenre>();
- qmlRegisterType<MLVideo>();
+ registerAnonymousType<MLAlbum>( "org.videolan.medialib", 1 );
+ registerAnonymousType<MLArtist>( "org.videolan.medialib", 1 );
+ registerAnonymousType<MLAlbumTrack>( "org.videolan.medialib", 1 );
+ registerAnonymousType<MLGenre>( "org.videolan.medialib", 1 );
+ registerAnonymousType<MLVideo>( "org.videolan.medialib", 1 );
}
qmlRegisterUncreatableType<NavigationHistory>("org.videolan.vlc", 0, 1, "History", "Type of global variable history" );
More information about the vlc-commits
mailing list