From: APTX Date: Mon, 27 Feb 2017 00:34:13 +0000 (+0100) Subject: Revert "Proper solution to Player QML registration" X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=bb6601aaa7e7eeee600beae5a8d49a5f73a39b25;p=aniplayer.git Revert "Proper solution to Player QML registration" This reverts commit 9ad7034db4f00a0a9cc586d49b89152501f5f611. This change breaks on Qt5.7, the workaround for 5.7 crashes on Qt5.8. --- diff --git a/core/player.cpp b/core/player.cpp index 56c5509..0be95be 100644 --- a/core/player.cpp +++ b/core/player.cpp @@ -7,7 +7,11 @@ Q_LOGGING_CATEGORY(playerCategory, "Player") Player::Player(BackendPluginBase *backendPlugin, QObject *parent) : QObject(parent) { - Q_ASSERT(backendPlugin); + if (!backendPlugin) { + qCCritical(playerCategory) + << "Trying to create a player without a backendPlugin"; + return; + } qCDebug(playerCategory) << "Creating player" << this; m_backend = backendPlugin->createInstance(this); Q_CHECK_PTR(m_backend); @@ -200,9 +204,7 @@ void Player::reqisterQmlTypes() { qRegisterMetaType("TimeStamp"); qRegisterMetaType("StreamIndex"); qRegisterMetaType("Volume"); - qmlRegisterUncreatableType( - "org.aptx.aniplayer", 1, 0, "Player", - "The player is provided to QML as the 'player' global variable."); + qmlRegisterType("org.aptx.aniplayer", 1, 0, "Player"); } bool Player::canLoadVideoNow() const { diff --git a/core/player.h b/core/player.h index e199fc1..c96d582 100644 --- a/core/player.h +++ b/core/player.h @@ -52,7 +52,9 @@ public: static const constexpr Volume MAX_VOLUME = Volume{1.0}; - explicit Player(BackendPluginBase *, QObject *parent = nullptr); + // BackendPluginBase * allowed to be null because this is exposed to QML + // for the enums/types. Player should never be created in QML. + explicit Player(BackendPluginBase * = nullptr, QObject *parent = nullptr); ~Player() override; enum class PlayState {