LCOV - code coverage report
Current view: top level - muse/framework/extensions/internal/legacy - extpluginrunner.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 18 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2024 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : #include "extpluginrunner.h"
      23              : 
      24              : #include <QQmlComponent>
      25              : 
      26              : #include "../../api/v1/ipluginapiv1.h"
      27              : #include "../../extensionserrors.h"
      28              : 
      29              : #include "log.h"
      30              : 
      31              : using namespace muse;
      32              : using namespace muse::extensions;
      33              : using namespace muse::extensions::legacy;
      34              : using namespace muse::extensions::apiv1;
      35              : 
      36            0 : Ret ExtPluginRunner::run(const Action& action)
      37              : {
      38            0 :     io::path_t qmlPath = action.path;
      39              : 
      40              :     //! NOTE We create extension UI using a separate engine to control what we provide,
      41              :     //! making it easier to maintain backward compatibility and stability.
      42            0 :     QQmlComponent component = QQmlComponent(engine()->qmlEngineApiV1(), qmlPath.toQString());
      43            0 :     if (!component.isReady()) {
      44            0 :         LOGE() << "Failed to load QML file: " << qmlPath;
      45            0 :         LOGE() << component.errorString();
      46            0 :         return make_ret(Err::ExtLoadError);
      47              :     }
      48              : 
      49            0 :     QObject* obj = component.create();
      50            0 :     if (!obj) {
      51            0 :         LOGE() << "Failed to create QML Object: " << qmlPath;
      52            0 :         return make_ret(Err::ExtLoadError);
      53              :     }
      54              : 
      55            0 :     IPluginApiV1* plugin = dynamic_cast<IPluginApiV1*>(obj);
      56            0 :     if (!plugin) {
      57            0 :         LOGE() << "Qml Object not MuseScore plugin: " << qmlPath;
      58            0 :         return make_ret(Err::ExtBadFormat);
      59              :     }
      60              : 
      61            0 :     plugin->runPlugin();
      62              : 
      63            0 :     return muse::make_ok();
      64            0 : }
        

Generated by: LCOV version 2.0-1