From 335976e32c2c70c5d17c9069dbf5b1414cb34695 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 12 Feb 2019 05:15:56 -0500 Subject: [PATCH] [partition] Improve defaultFS handling - drop the localized comparisons; that's just confusing - warn when no default FS is set (then use ext4) - fix case-insensitive fallback; it used fsType, which was set to Unknown in the for loop. --- .../partition/gui/PartitionViewStep.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index b7433450d..a152db14b 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -503,30 +503,23 @@ findFS( QString defaultFS ) { QStringList fsLanguage { QLatin1Literal( "C" ) }; // Required language list to turn off localization if ( defaultFS.isEmpty() ) + { + cWarning() << "Partition-module setting *defaultFileSystemType* is missing, using ext4"; defaultFS = QStringLiteral( "ext4" ); + } if ( FileSystem::typeForName( defaultFS, fsLanguage ) != FileSystem::Unknown ) { cDebug() << "Partition-module setting *defaultFileSystemType*" << defaultFS; return defaultFS; } - // First pass: try the default language instead of C locale - auto fsType = FileSystem::typeForName( defaultFS ); - if ( fsType != FileSystem::Unknown ) - { - defaultFS = FileSystem::nameForType( fsType, fsLanguage ); - cWarning() << "Partition-module setting *defaultFileSystemType* changed" << defaultFS; - return defaultFS; - } - - // Second pass: try case-insensitive, both unlocalized and localized + // Second pass: try case-insensitive const auto fstypes = FileSystem::types(); for ( FileSystem::Type t : fstypes ) { - if ( ( 0 == QString::compare( defaultFS, FileSystem::nameForType( t, fsLanguage ), Qt::CaseInsensitive ) ) || - ( 0 == QString::compare( defaultFS, FileSystem::nameForType( t ), Qt::CaseInsensitive ) ) ) + if ( 0 == QString::compare( defaultFS, FileSystem::nameForType( t, fsLanguage ), Qt::CaseInsensitive ) ) { - defaultFS = FileSystem::nameForType( fsType, fsLanguage ); + defaultFS = FileSystem::nameForType( t, fsLanguage ); cWarning() << "Partition-module setting *defaultFileSystemType* changed" << defaultFS; return defaultFS; }