From 43a969d73bfc920456c3bf40c1827864551aa1f5 Mon Sep 17 00:00:00 2001
From: Elliu <elliu@hashi.re>
Date: Thu, 21 Jul 2022 20:02:09 +0200
Subject: [PATCH] Correctly check for key validity on .vivy loading

Replace QJsonValue.isNull() with QJsonValue.isUndefined()
---
 src/Lib/Document/VivyDocument.cc | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Lib/Document/VivyDocument.cc b/src/Lib/Document/VivyDocument.cc
index f9406f5e..59dec54c 100644
--- a/src/Lib/Document/VivyDocument.cc
+++ b/src/Lib/Document/VivyDocument.cc
@@ -72,18 +72,18 @@ VivyDocument::loadSaveJsonDocumentFile_ALPHA(VivyDocument *const self, const QJs
         throw std::runtime_error("The document was edited outside of Vivy");
 
     if (QJsonValue audio = json[KeySubDocuments][KeySubAudio];
-        !audio.isNull() && !self->loadSubDocument(audio.toString(), Capabilities::AudioAble))
+        !audio.isUndefined() && !self->loadSubDocument(audio.toString(), Capabilities::AudioAble))
         throw std::runtime_error("Failed to load audio sub document");
 
     if (QJsonValue video = json[KeySubDocuments][KeySubVideo];
-        !video.isNull() && !self->loadSubDocument(video.toString(), Capabilities::VideoAble))
+        !video.isUndefined() && !self->loadSubDocument(video.toString(), Capabilities::VideoAble))
         throw std::runtime_error("Failed to load video sub document");
 
     if (QJsonValue internalAssSource = json[KeySubDocuments][KeyInternalAssSource];
-        !internalAssSource.isNull() && internalAssSource.toBool()) {
+        !internalAssSource.isUndefined() && internalAssSource.toBool()) {
         // ASS is inside Vivy document
         throw std::runtime_error("The internal ASS feature is not supported for now");
-    } else if (QJsonValue ass = json[KeySubDocuments][KeySubAss]; !ass.isNull()) {
+    } else if (QJsonValue ass = json[KeySubDocuments][KeySubAss]; !ass.isUndefined()) {
         // ASS in its own ASS file
         if (!self->loadSubDocument(ass.toString(), Capabilities::AssAble))
             throw std::runtime_error("Failed to load ASS sub document");
@@ -98,7 +98,7 @@ VivyDocument::loadSaveJsonDocumentFile(const QJsonDocument &json)
                                "document to this function");
 
     const QJsonValue savedVersionJson = json[KeyDocumentVersion];
-    if (savedVersionJson.isNull())
+    if (savedVersionJson.isUndefined())
         throw std::runtime_error("No version present in the saved VivyDocument");
 
     const QString savedVersion = savedVersionJson.toString();
-- 
GitLab