diff --git a/src/modules/partition/core/KPMHelpers.cpp b/src/modules/partition/core/KPMHelpers.cpp index 3630ab751..c3d4c07cc 100644 --- a/src/modules/partition/core/KPMHelpers.cpp +++ b/src/modules/partition/core/KPMHelpers.cpp @@ -37,25 +37,6 @@ using CalamaresUtils::Partition::PartitionIterator; namespace KPMHelpers { -static bool s_KPMcoreInited = false; - -bool -initKPMcore() -{ - if ( s_KPMcoreInited ) - return true; - - QByteArray backendName = qgetenv( "KPMCORE_BACKEND" ); - if ( !CoreBackendManager::self()->load( backendName.isEmpty() ? CoreBackendManager::defaultBackendName() : backendName ) ) - { - cWarning() << "Failed to load backend plugin" << backendName; - return false; - } - s_KPMcoreInited = true; - return true; -} - - Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ) { diff --git a/src/modules/partition/core/KPMHelpers.h b/src/modules/partition/core/KPMHelpers.h index 4ec10fe96..5e18aaf3a 100644 --- a/src/modules/partition/core/KPMHelpers.h +++ b/src/modules/partition/core/KPMHelpers.h @@ -50,19 +50,6 @@ class PartitionRole; namespace KPMHelpers { -/** - * Thin wrapper on top of CoreBackendManager. Hides things like initializing the - * Config instance or instantiating the backend. - * - * Initialize PartitionManager Config object and load a PartitionManager - * backend. It loads the "libparted" plugin by default, but this can be - * overloaded by settings the environment variable KPMCORE_BACKEND. Setting it to - * "dummy" will load the dummy plugin instead. - * - * @return true if initialization was successful. - */ -bool initKPMcore(); - /** * Iterates on all devices and return the first partition which is associated * with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint() diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index ef9b8ccfe..cd5d009f0 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -147,7 +147,7 @@ PartitionCoreModule::PartitionCoreModule( QObject* parent ) , m_deviceModel( new DeviceModel( this ) ) , m_bootLoaderModel( new BootLoaderModel( this ) ) { - if ( !KPMHelpers::initKPMcore() ) + if ( !m_kpmcore ) qFatal( "Failed to initialize KPMcore backend" ); } diff --git a/src/modules/partition/core/PartitionCoreModule.h b/src/modules/partition/core/PartitionCoreModule.h index 7faf67863..aaae67bab 100644 --- a/src/modules/partition/core/PartitionCoreModule.h +++ b/src/modules/partition/core/PartitionCoreModule.h @@ -26,6 +26,7 @@ #include "core/PartitionModel.h" #include "Job.h" +#include "partition/KPMManager.h" // KPMcore #include @@ -235,6 +236,8 @@ Q_SIGNALS: void deviceReverted( Device* device ); private: + CalamaresUtils::Partition::KPMManager m_kpmcore; + void refreshAfterModelChange(); /** diff --git a/src/modules/partition/tests/PartitionJobTests.cpp b/src/modules/partition/tests/PartitionJobTests.cpp index 28970e4b5..ae1f37784 100644 --- a/src/modules/partition/tests/PartitionJobTests.cpp +++ b/src/modules/partition/tests/PartitionJobTests.cpp @@ -19,7 +19,9 @@ #include +#include "partition/KPMManager.h" #include "partition/PartitionQuery.h" +#include "utils/Logger.h" #include "utils/Units.h" #include @@ -163,6 +165,8 @@ QueueRunner::onFailed( const QString& message, const QString& details ) QFAIL( qPrintable( msg ) ); } +CalamaresUtils::Partition::KPMManager* kpmcore = nullptr; + //- PartitionJobTests ------------------------------------------------------------------ PartitionJobTests::PartitionJobTests() : m_runner( &m_queue ) @@ -178,12 +182,18 @@ PartitionJobTests::initTestCase() QSKIP( "Skipping test, CALAMARES_TEST_DISK is not set. It should point to a disk which can be safely formatted", 0 ); } - QVERIFY( KPMHelpers::initKPMcore() ); + kpmcore = new CalamaresUtils::Partition::KPMManager(); FileSystemFactory::init(); refreshDevice(); } +void +PartitionJobTests::cleanupTestCase() +{ + delete kpmcore; +} + void PartitionJobTests::refreshDevice() { diff --git a/src/modules/partition/tests/PartitionJobTests.h b/src/modules/partition/tests/PartitionJobTests.h index 62d5924ea..bfa1d6707 100644 --- a/src/modules/partition/tests/PartitionJobTests.h +++ b/src/modules/partition/tests/PartitionJobTests.h @@ -59,6 +59,7 @@ public: private Q_SLOTS: void initTestCase(); + void cleanupTestCase(); void testPartitionTable(); void testCreatePartition(); void testCreatePartitionExtended();