]> Some of my projects - aniplayer.git/commitdiff
Revert "Proper solution to Player QML registration"
authorAPTX <marek321@gmail.com>
Mon, 27 Feb 2017 00:34:13 +0000 (01:34 +0100)
committerAPTX <marek321@gmail.com>
Mon, 27 Feb 2017 00:34:13 +0000 (01:34 +0100)
This reverts commit 9ad7034db4f00a0a9cc586d49b89152501f5f611.

This change breaks on Qt5.7, the workaround for 5.7 crashes
on Qt5.8.

core/player.cpp
core/player.h

index 56c55092e13a3be719bbb5e606f1cbf55778b8ec..0be95be021734f79bb5fd169eb2b3b16a183ded3 100644 (file)
@@ -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>("TimeStamp");
   qRegisterMetaType<StreamIndex>("StreamIndex");
   qRegisterMetaType<Volume>("Volume");
-  qmlRegisterUncreatableType<Player>(
-      "org.aptx.aniplayer", 1, 0, "Player",
-      "The player is provided to QML as the 'player' global variable.");
+  qmlRegisterType<Player>("org.aptx.aniplayer", 1, 0, "Player");
 }
 
 bool Player::canLoadVideoNow() const {
index e199fc1d06073d4eccae47f33fea6f56dbcdbbd6..c96d582900993cde87b322cb1922b2e69c0621c3 100644 (file)
@@ -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 {