[vlc-devel] [PATCH] qt: main_interface: remove deprecation warning on qmlRegisterType

Alexandre Janniaux ajanni at videolabs.io
Wed Apr 8 17:55:31 CEST 2020


Hi,

Thanks for review, fine with me.

I will put the template function in an anonymous namespace
at the top of the .cpp file, as it's not used anywhere else.

Regards,
--
Alexandre Janniaux
Videolabs

On Wed, Apr 08, 2020 at 04:39:23PM +0200, Jean-Baptiste Kempf wrote:
> LGTM.
>
> However, I would put this generic fonction in a different file, tbh.
>
> On Mon, Apr 6, 2020, at 15:55, Alexandre Janniaux wrote:
> > 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.
> > ---
> >  modules/gui/qt/maininterface/main_interface.cpp | 10 +++++-----
> >  modules/gui/qt/maininterface/main_interface.hpp | 15 +++++++++++++++
> >  2 files changed, 20 insertions(+), 5 deletions(-)
> >
> > diff --git a/modules/gui/qt/maininterface/main_interface.cpp
> > b/modules/gui/qt/maininterface/main_interface.cpp
> > index 8027b116cb..3bc869cd35 100644
> > --- a/modules/gui/qt/maininterface/main_interface.cpp
> > +++ b/modules/gui/qt/maininterface/main_interface.cpp
> > @@ -357,11 +357,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" );
> > diff --git a/modules/gui/qt/maininterface/main_interface.hpp
> > b/modules/gui/qt/maininterface/main_interface.hpp
> > index 9333d9918d..e04ae8b1d8 100644
> > --- a/modules/gui/qt/maininterface/main_interface.hpp
> > +++ b/modules/gui/qt/maininterface/main_interface.hpp
> > @@ -30,6 +30,7 @@
> >  #include "player/player_controller.hpp"
> >  #include "voutwindow/qvoutwindow.hpp"
> >
> > +#include <QtGlobal>
> >  #include <QSystemTrayIcon>
> >  #include <QStackedWidget>
> >  #include <QtQuick/QQuickView>
> > @@ -262,6 +263,20 @@ signals:
> >      void hasEmbededVideoChanged(bool);
> >      void toolBarConfUpdated();
> >      void showRemainingTimeChanged(bool);
> > +
> > +private:
> > +    template<class T>
> > +    void registerAnonymousType( const char *uri, int versionMajor );
> >  };
> >
> > +template<class T>
> > +void MainInterface::registerAnonymousType( const char *uri, int versionMajor )
> > +{
> > +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
> > +    qmlRegisterAnonymousType<T>( uri, versionMajor );
> > +#else
> > +    qmlRegisterType<T>();
> > +#endif
> > +}
> > +
> >  #endif
> > --
> > 2.26.0
> >
> > _______________________________________________
> > vlc-devel mailing list
> > To unsubscribe or modify your subscription options:
> > https://mailman.videolan.org/listinfo/vlc-devel
>
> --
> Jean-Baptiste Kempf -  President
> +33 672 704 734
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list