From 56b46cd37e9d335f635ef5f5da11cf06d80d28bf Mon Sep 17 00:00:00 2001
From: Kubat <mael.martin31@gmail.com>
Date: Mon, 6 Nov 2023 20:35:09 +0100
Subject: [PATCH] MISC: Can only execute a script on a vivy document...

---
 CMakeLists.txt                |  2 +-
 src/Lib/Script/ScriptStore.cc | 10 ++--------
 src/Lib/Script/ScriptStore.hh |  1 -
 src/UI/MainWindow.cc          | 16 +++-------------
 4 files changed, 6 insertions(+), 23 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 72ea3327..f5d95c03 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -112,7 +112,7 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
 
         # Qt generated files...
         -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-c++98-c++11-c++14-c++17-compat-pedantic -Wno-c++20-compat
-        -Wno-unsafe-buffer-usage -Wno-unused-parameter
+        -Wno-unsafe-buffer-usage
 
         # Different versions of MPV...
         -Wno-switch-enum
diff --git a/src/Lib/Script/ScriptStore.cc b/src/Lib/Script/ScriptStore.cc
index b3e20da7..1d245bf9 100644
--- a/src/Lib/Script/ScriptStore.cc
+++ b/src/Lib/Script/ScriptStore.cc
@@ -38,16 +38,10 @@ ScriptStore::resetLoadedScripts() noexcept
     logInfo() << "TODO";
 }
 
-bool
-ScriptStore::executeScript(Uuid id) noexcept
-{
-    logInfo() << "TODO";
-    return false;
-}
-
 bool
 ScriptStore::executeScript(Uuid id, std::shared_ptr<Vivy::VivyDocument> doc) noexcept
 {
-    logInfo() << "TODO";
+    logInfo() << "TODO: execute script " << VIVY_LOG_QUOTED(id) << " on document "
+              << VIVY_LOG_QUOTED(doc->getUuid());
     return false;
 }
diff --git a/src/Lib/Script/ScriptStore.hh b/src/Lib/Script/ScriptStore.hh
index 8e10eabb..2684d9bb 100644
--- a/src/Lib/Script/ScriptStore.hh
+++ b/src/Lib/Script/ScriptStore.hh
@@ -25,7 +25,6 @@ public:
     void resetLoadedScripts() noexcept;
     void loadScriptFolder(const QString &folderPath);
     std::vector<Item> getLoadedScripts() const noexcept;
-    bool executeScript(Uuid) noexcept;
     bool executeScript(Uuid, std::shared_ptr<Vivy::VivyDocument>) noexcept;
 
     // Get modules from scripts
diff --git a/src/UI/MainWindow.cc b/src/UI/MainWindow.cc
index d8b741c4..2b71ba64 100644
--- a/src/UI/MainWindow.cc
+++ b/src/UI/MainWindow.cc
@@ -310,20 +310,10 @@ MainWindow::openDocument() noexcept
 
     // Handle the different types here
     try {
-        if (fileType == Utils::DocumentType::Vivy)
+        if (fileType == Utils::DocumentType::Vivy) {
             addTab(new VivyDocumentView(vivyApp->documentStore->loadDocument(filename), documents));
-
-        else if (fileType == Utils::DocumentType::VivyScript) {
-            auto scriptDocument = vivyApp->scriptStore->loadDocument(filename);
-            const bool rc       = vivyApp->scriptStore->executeScript(scriptDocument->getUuid());
-            ScriptDocumentView *newView = new ScriptDocumentView(scriptDocument, documents);
-
-            if (!rc) {
-                logError() << "Failed to execute script document " << VIVY_LOG_QUOTED(filename)
-                           << " with code: " << rc;
-            }
-
-            addTab(newView);
+        } else if (fileType == Utils::DocumentType::VivyScript) {
+            addTab(new ScriptDocumentView(vivyApp->scriptStore->loadDocument(filename), documents));
         }
     } catch (const std::runtime_error &e) {
         logError() << "Failed to load document " << VIVY_LOG_QUOTED(filename)
-- 
GitLab