From 37d99b7eaadef6dacbfcde9d9ef84fd9ff7528ba Mon Sep 17 00:00:00 2001 From: Emir SARI Date: Tue, 21 Mar 2023 17:37:34 +0300 Subject: [PATCH] NumberFormat: Fix incorrect fallback logic We need to assign the fallback value to the temporary variable, otherwise there is a broken if logic in case the percent is not formattable. Change-Id: I90593fdf8ec29b802dff02c2fbe5d7ac40cea2ff Reviewed-on: https://review.haiku-os.org/c/haiku/+/6238 Tested-by: Automation Reviewed-by: waddlesplash --- src/apps/mediaconverter/MediaConverterApp.cpp | 6 ++---- src/apps/mediaconverter/MediaConverterWindow.cpp | 8 ++++---- src/apps/showimage/ShowImageStatusView.cpp | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/apps/mediaconverter/MediaConverterApp.cpp b/src/apps/mediaconverter/MediaConverterApp.cpp index 4d5b4704d3..02b4c9b197 100644 --- a/src/apps/mediaconverter/MediaConverterApp.cpp +++ b/src/apps/mediaconverter/MediaConverterApp.cpp @@ -591,8 +591,7 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile, double percentValue = (double)currPercent; if (fNumberFormat.FormatPercent(data, percentValue / 100) != B_OK) { - status.SetToFormat(B_TRANSLATE("Writing video track: %" B_PRId32 - "%% complete"), currPercent); + data.SetToFormat("%" B_PRId32 "%%", currPercent); } status.SetToFormat(B_TRANSLATE("Writing video track: %s complete"), data.String()); @@ -649,8 +648,7 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile, double percentValue = (double)currPercent; if (fNumberFormat.FormatPercent(data, percentValue / 100) != B_OK) { - status.SetToFormat(B_TRANSLATE("Writing audio track: %" B_PRId32 - "%% complete"), currPercent); + data.SetToFormat("%" B_PRId32 "%%", currPercent); } status.SetToFormat(B_TRANSLATE("Writing audio track: %s complete"), data.String()); diff --git a/src/apps/mediaconverter/MediaConverterWindow.cpp b/src/apps/mediaconverter/MediaConverterWindow.cpp index d831b6f726..9252cc3572 100644 --- a/src/apps/mediaconverter/MediaConverterWindow.cpp +++ b/src/apps/mediaconverter/MediaConverterWindow.cpp @@ -497,7 +497,7 @@ MediaConverterWindow::MessageReceived(BMessage* message) double percentValue = value / 100.0; if (fNumberFormat.FormatPercent(data, percentValue) != B_OK) - buffer.SetToFormat(B_TRANSLATE("Video quality: %d%%"), (int8)value); + data.SetToFormat("%d%%", (int8)value); buffer.SetToFormat(B_TRANSLATE("Video quality: %s"), data.String()); fVideoQualitySlider->SetLabel(buffer.String()); @@ -514,7 +514,7 @@ MediaConverterWindow::MessageReceived(BMessage* message) double percentValue = value / 100.0; if (fNumberFormat.FormatPercent(data, percentValue) != B_OK) - buffer.SetToFormat(B_TRANSLATE("Audio quality: %d%%"), (int8)value); + data.SetToFormat("%d%%", (int8)value); buffer.SetToFormat(B_TRANSLATE("Audio quality: %s"), data.String()); fAudioQualitySlider->SetLabel(buffer.String()); @@ -940,7 +940,7 @@ MediaConverterWindow::_UpdateLabels() double percentValue = fVideoQuality / 100.0; if (fNumberFormat.FormatPercent(data, percentValue) != B_OK) - buffer.SetToFormat(B_TRANSLATE("Video quality: %d%%"), (int8)fVideoQuality); + data.SetToFormat("%d%%", (int8)fVideoQuality); buffer.SetToFormat(B_TRANSLATE("Video quality: %s"), data.String()); fVideoQuality = (int)percentValue; @@ -954,7 +954,7 @@ MediaConverterWindow::_UpdateLabels() double percentValue = fAudioQuality / 100.0; if (fNumberFormat.FormatPercent(data, percentValue) != B_OK) { - buffer.SetToFormat(B_TRANSLATE("Audio quality: %d%%"), (int8)fAudioQuality); + data.SetToFormat("%d%%", (int8)fAudioQuality); } buffer.SetToFormat(B_TRANSLATE("Audio quality: %s"), data.String()); diff --git a/src/apps/showimage/ShowImageStatusView.cpp b/src/apps/showimage/ShowImageStatusView.cpp index 327cb1fd17..58c4414101 100644 --- a/src/apps/showimage/ShowImageStatusView.cpp +++ b/src/apps/showimage/ShowImageStatusView.cpp @@ -183,7 +183,7 @@ ShowImageStatusView::_SetZoomText(float zoom) BString data; if (numberFormat.FormatPercent(data, zoom) != B_OK) - fCellText[kZoomCell].SetToFormat("%.0f%%", zoom * 100); + data.SetToFormat("%.0f%%", zoom * 100); fCellText[kZoomCell] = data; }