[partition] Handle KPMcore deprecations

This commit is contained in:
Adriaan de Groot 2024-12-20 13:28:05 +01:00
parent e4b198d13b
commit 98f47ee407
2 changed files with 13 additions and 3 deletions

View file

@ -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

View file

@ -54,6 +54,16 @@
#include <QPointer>
#include <QtConcurrent/QtConcurrent>
///@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();