From adf2fa32500d33417b6e6ac9e2867f3ab3eede34 Mon Sep 17 00:00:00 2001
From: Alexander Golubev <fatzer2@gmail.com>
Date: Sun, 3 Aug 2025 02:34:04 +0300
Subject: 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>
---
 src/importers/mxpimporter.cpp        | 2 +-
 src/importers/nycgenericimporter.cpp | 4 ++--
 src/importers/recipemlimporter.cpp   | 6 +++---
 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 5ad07eb..e4c830d 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 fee7f66..c065596 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 220f623..fdb3b61 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;
 }
-- 
cgit v1.2.3

