From 98f47ee407bf714a3a64757e926ba08971dbb020 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 20 Dec 2024 13:28:05 +0100 Subject: [PATCH] [partition] Handle KPMcore deprecations --- CMakeModules/KPMcoreHelper.cmake | 4 ++-- src/modules/partition/gui/PartitionPage.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeModules/KPMcoreHelper.cmake b/CMakeModules/KPMcoreHelper.cmake index cdbd2336f..f69d20518 100644 --- a/CMakeModules/KPMcoreHelper.cmake +++ b/CMakeModules/KPMcoreHelper.cmake @@ -41,8 +41,8 @@ if(NOT TARGET calapmcore) target_link_libraries(calapmcore INTERFACE kpmcore ${qtname}::DBus ${kfname}::I18n ${kfname}::WidgetsAddons) target_include_directories(calapmcore INTERFACE ${KPMCORE_INCLUDE_DIR}) - # If there were KPMcore API variations, figure them out here - # target_compile_definitions(calapmcore INTERFACE WITH_KPMcore) + math(EXPR _kpm_version_number "(0x${KPMcore_VERSION_MAJOR} * 0x10000)+(0x${KPMcore_VERSION_MINOR} * 0x100)+(0x${KPMcore_VERSION_PATCH})" OUTPUT_FORMAT HEXADECIMAL) + target_compile_definitions(calapmcore INTERFACE WITH_KPMcore=${_kpm_version_number}) # Flag that this library has KPMcore support. A variable # set here has the wrong scope. ENV{} would be visible diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index 7f1f8be1b..6a4accfa3 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -54,6 +54,16 @@ #include #include +///@brief At some point the msdos_sectorbased partition table type was retired +static bool isMSDOSPartition(PartitionTable::TableType t) +{ +#if WITH_KPMcore > 0x240801 + return t == PartitionTable::TableType::msdos; +#else + return t == PartitionTable::TableType::msdos || t == PartitionTable::TableType::msdos_sectorbased; +#endif +} + PartitionPage::PartitionPage( PartitionCoreModule* core, const Config & config, QWidget* parent ) : QWidget( parent ) , m_ui( new Ui_PartitionPage ) @@ -253,7 +263,7 @@ PartitionPage::checkCanCreate( Device* device ) { auto table = device->partitionTable(); - if ( table->type() == PartitionTable::msdos || table->type() == PartitionTable::msdos_sectorbased ) + if ( isMSDOSPartition( table->type() ) ) { cDebug() << "Checking MSDOS partition" << table->numPrimaries() << "primaries, max" << table->maxPrimaries();