LCOV - code coverage report
Current view: top level - src/engraving - engravingproject.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 0.0 % 70 0
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 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 "engravingproject.h"
      23              : 
      24              : #include "global/allocator.h"
      25              : 
      26              : #include "rw/inoutdata.h"
      27              : #include "rw/mscloader.h"
      28              : #include "rw/mscsaver.h"
      29              : #include "style/defaultstyle.h"
      30              : #include "dom/masterscore.h"
      31              : #include "dom/part.h"
      32              : 
      33              : #include "log.h"
      34              : 
      35              : using namespace muse;
      36              : using namespace mu;
      37              : using namespace mu::engraving;
      38              : 
      39            0 : std::shared_ptr<EngravingProject> EngravingProject::create(const modularity::ContextPtr& iocCtx)
      40              : {
      41            0 :     std::shared_ptr<EngravingProject> p = std::shared_ptr<EngravingProject>(new EngravingProject(iocCtx));
      42            0 :     if (p->engravingElementsProvider()) {
      43            0 :         p->engravingElementsProvider()->clearStatistic();
      44              :     }
      45            0 :     p->init(DefaultStyle::defaultStyle());
      46            0 :     return p;
      47            0 : }
      48              : 
      49            0 : std::shared_ptr<EngravingProject> EngravingProject::create(const MStyle& style, const modularity::ContextPtr& iocCtx)
      50              : {
      51            0 :     std::shared_ptr<EngravingProject> p = std::shared_ptr<EngravingProject>(new EngravingProject(iocCtx));
      52            0 :     if (p->engravingElementsProvider()) {
      53            0 :         p->engravingElementsProvider()->clearStatistic();
      54              :     }
      55            0 :     p->init(style);
      56            0 :     return p;
      57            0 : }
      58              : 
      59            0 : EngravingProject::EngravingProject(const modularity::ContextPtr& iocCtx)
      60            0 :     : muse::Contextable(iocCtx)
      61              : {
      62            0 :     muse::ObjectAllocator::used();
      63            0 : }
      64              : 
      65            0 : EngravingProject::~EngravingProject()
      66              : {
      67            0 :     delete m_masterScore;
      68              : 
      69            0 :     muse::ObjectAllocator::unused();
      70              : 
      71              :     // muse::AllocatorsRegister::instance()->printStatistic("=== Destroy engraving project ===");
      72              :     //! NOTE At the moment, the allocator is working as leak detector. No need to do cleanup, at the moment it can lead to crashes
      73              :     // AllocatorsRegister::instance()->cleanupAll("engraving");
      74            0 : }
      75              : 
      76            0 : void EngravingProject::init(const MStyle& style)
      77              : {
      78            0 :     m_masterScore = new MasterScore(iocContext(), style, weak_from_this());
      79            0 : }
      80              : 
      81            0 : IFileInfoProviderPtr EngravingProject::fileInfoProvider() const
      82              : {
      83            0 :     return m_masterScore->fileInfo();
      84              : }
      85              : 
      86            0 : void EngravingProject::setFileInfoProvider(IFileInfoProviderPtr fileInfoProvider)
      87              : {
      88            0 :     m_masterScore->setFileInfoProvider(fileInfoProvider);
      89            0 : }
      90              : 
      91            0 : String EngravingProject::appVersion() const
      92              : {
      93            0 :     return m_masterScore->mscoreVersion();
      94              : }
      95              : 
      96            0 : int EngravingProject::mscVersion() const
      97              : {
      98            0 :     return m_masterScore->mscVersion();
      99              : }
     100              : 
     101            0 : bool EngravingProject::readOnly() const
     102              : {
     103            0 :     return m_masterScore->readOnly();
     104              : }
     105              : 
     106            0 : void EngravingProject::setMasterScore(MasterScore* score)
     107              : {
     108            0 :     m_masterScore = score;
     109            0 : }
     110              : 
     111            0 : Ret EngravingProject::setupMasterScore(bool forceMode)
     112              : {
     113            0 :     TRACEFUNC;
     114              : 
     115            0 :     m_masterScore->updatePaddingTables();
     116            0 :     for (Score* s : m_masterScore->scoreList()) {
     117            0 :         s->updatePaddingTables();
     118            0 :     }
     119              : 
     120            0 :     m_masterScore->setLayoutAll();
     121            0 :     m_masterScore->update();
     122            0 :     m_masterScore->initAutomation();
     123              : 
     124            0 :     Ret ret = checkCorrupted();
     125            0 :     m_isCorruptedUponLoading = !ret;
     126              : 
     127            0 :     return forceMode ? muse::make_ok() : ret;
     128            0 : }
     129              : 
     130            0 : MasterScore* EngravingProject::masterScore() const
     131              : {
     132            0 :     return m_masterScore;
     133              : }
     134              : 
     135            0 : Ret EngravingProject::loadMscz(const MscReader& msc, rw::ReadInOutData* data, bool ignoreVersionError)
     136              : {
     137            0 :     TRACEFUNC;
     138              : 
     139            0 :     MScore::setError(MsError::MS_NO_ERROR);
     140              : 
     141              :     MscLoader loader;
     142            0 :     return loader.loadMscz(m_masterScore, msc, data, ignoreVersionError);
     143            0 : }
     144              : 
     145            0 : bool EngravingProject::writeMscz(MscWriter& writer, bool createThumbnail, const write::WriteContext* ctx)
     146              : {
     147            0 :     TRACEFUNC;
     148              : 
     149            0 :     MscSaver saver(iocContext());
     150            0 :     return saver.writeMscz(m_masterScore, writer, createThumbnail, ctx);
     151            0 : }
     152              : 
     153            0 : bool EngravingProject::isCorruptedUponLoading() const
     154              : {
     155            0 :     return m_isCorruptedUponLoading;
     156              : }
     157              : 
     158            0 : Ret EngravingProject::checkCorrupted() const
     159              : {
     160            0 :     TRACEFUNC;
     161              : 
     162            0 :     return m_masterScore->sanityCheck();
     163            0 : }
        

Generated by: LCOV version 2.0-1