diff options
| author | Alexander Golubev <fatzer2@gmail.com> | 2025-08-03 02:34:04 +0300 |
|---|---|---|
| committer | Alexander Golubev <fatzer2@gmail.com> | 2025-08-04 03:34:06 +0300 |
| commit | 7b2d5032f9573eaafa300a3159971e37125fd2d9 (patch) | |
| tree | 3c607af6e7b30df63665f1ff6a950cd559152fb0 | |
| parent | 84991f49a0ab963597b697d99e9f3c1c6c9053ee (diff) | |
| download | krecipes-7b2d5032.tar.gz krecipes-7b2d5032.zip | |
Use locale-unaware functions when importing files
Locale-aware version of MixedNumber::fromString() were causing problems
when locale has a different decimal separator than dot (`.`).
Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
(cherry picked from commit adf2fa32500d33417b6e6ac9e2867f3ab3eede34)
| -rw-r--r-- | src/importers/mxpimporter.cpp | 2 | ||||
| -rw-r--r-- | src/importers/nycgenericimporter.cpp | 4 | ||||
| -rw-r--r-- | src/importers/recipemlimporter.cpp | 6 | ||||
| -rw-r--r-- | src/importers/rezkonvimporter.cpp | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/importers/mxpimporter.cpp b/src/importers/mxpimporter.cpp index 9a0221f..c43fc4c 100644 --- a/src/importers/mxpimporter.cpp +++ b/src/importers/mxpimporter.cpp @@ -182,7 +182,7 @@ void MXPImporter::loadIngredients( TQTextStream &stream, Recipe &recipe ) if ( !amount_str.isEmpty() ) // case of amount_str.isEmpty() correctly handled by class default { bool ok; - MixedNumber amount( MixedNumber::fromString( amount_str, &ok ) ); + MixedNumber amount( MixedNumber::fromString( amount_str, &ok, /* locale_aware = */ false ) ); if ( !ok ) { addWarningMsg( TQString( i18n( "While loading recipe \"%1\" Invalid amount \"%2\" in the line \"%3\"" ) ).arg( recipe.title ).arg( amount_str ).arg( current.stripWhiteSpace() ) ); diff --git a/src/importers/nycgenericimporter.cpp b/src/importers/nycgenericimporter.cpp index 30e5bdf..d2b55a0 100644 --- a/src/importers/nycgenericimporter.cpp +++ b/src/importers/nycgenericimporter.cpp @@ -152,7 +152,7 @@ void NYCGenericImporter::loadIngredientLine( const TQString &line ) if ( !ingredient_line.empty() ) //probably an unnecessary check... but to be safe { bool ok; - MixedNumber test_amount = MixedNumber::fromString( ingredient_line[ 0 ], &ok ); + MixedNumber test_amount = MixedNumber::fromString( ingredient_line[ 0 ], &ok, /* locale_aware = */ false ); if ( ok ) { amount = amount + test_amount; @@ -163,7 +163,7 @@ void NYCGenericImporter::loadIngredientLine( const TQString &line ) if ( !ingredient_line.empty() ) //probably an unnecessary check... but to be safe { bool ok; - MixedNumber test_amount = MixedNumber::fromString( ingredient_line[ 0 ], &ok ); + MixedNumber test_amount = MixedNumber::fromString( ingredient_line[ 0 ], &ok, /* locale_aware = */ false ); if ( ok ) { amount = amount + test_amount; diff --git a/src/importers/recipemlimporter.cpp b/src/importers/recipemlimporter.cpp index 8866648..c5fa51a 100644 --- a/src/importers/recipemlimporter.cpp +++ b/src/importers/recipemlimporter.cpp @@ -350,7 +350,7 @@ void RecipeMLImporter::readRecipemlTQty( const TQDomElement &qty, Ingredient &in if ( tagName == "range" ) readRecipemlRange( qtyChild, ing.amount, ing.amount_offset ); else if ( tagName.isEmpty() ) - ing.amount = MixedNumber::fromString( qty.text() ).toDouble(); + ing.amount = MixedNumber::fromString( qty.text(), nullptr, /* locale_aware= */ false ).toDouble(); else kdDebug() << "Unknown tag within <qty>: " << tagName << endl; } @@ -364,9 +364,9 @@ void RecipeMLImporter::readRecipemlRange( const TQDomElement& range, double &amo TQDomElement rangeChild = rangeChilds.item( j ).toElement(); TQString subTagName = rangeChild.tagName(); if ( subTagName == "q1" ) - q1 = MixedNumber::fromString( rangeChild.text() ).toDouble(); + q1 = MixedNumber::fromString( rangeChild.text(), nullptr, /* locale_aware= */ false ).toDouble(); else if ( subTagName == "q2" ) - q2 = MixedNumber::fromString( rangeChild.text() ).toDouble(); + q2 = MixedNumber::fromString( rangeChild.text(), nullptr, /* locale_aware= */ false ).toDouble(); else kdDebug() << "Unknown tag within <range>: " << subTagName << endl; } diff --git a/src/importers/rezkonvimporter.cpp b/src/importers/rezkonvimporter.cpp index 49a1e0b..450bcf5 100644 --- a/src/importers/rezkonvimporter.cpp +++ b/src/importers/rezkonvimporter.cpp @@ -281,8 +281,8 @@ void RezkonvImporter::readRange( const TQString &range_str, double &amount, doub TQString from = range_str.section( '-', 0, 0 ); TQString to = range_str.section( '-', 1, 1 ); - amount = MixedNumber::fromString( from ).toDouble(); + amount = MixedNumber::fromString( from, nullptr, /* locale_aware = */ false ).toDouble(); if ( !to.stripWhiteSpace().isEmpty() ) - amount_offset = MixedNumber::fromString( to ).toDouble() - amount; + amount_offset = MixedNumber::fromString( to, nullptr, /* locale_aware = */ false ).toDouble() - amount; } |
