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 <automation@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Emir SARI 2023-03-21 17:37:34 +03:00 committed by waddlesplash
parent d2283cd881
commit 37d99b7eaa
3 changed files with 7 additions and 9 deletions

View File

@ -591,8 +591,7 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
double percentValue = (double)currPercent; double percentValue = (double)currPercent;
if (fNumberFormat.FormatPercent(data, percentValue / 100) != B_OK) { if (fNumberFormat.FormatPercent(data, percentValue / 100) != B_OK) {
status.SetToFormat(B_TRANSLATE("Writing video track: %" B_PRId32 data.SetToFormat("%" B_PRId32 "%%", currPercent);
"%% complete"), currPercent);
} }
status.SetToFormat(B_TRANSLATE("Writing video track: %s complete"), data.String()); 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; double percentValue = (double)currPercent;
if (fNumberFormat.FormatPercent(data, percentValue / 100) != B_OK) { if (fNumberFormat.FormatPercent(data, percentValue / 100) != B_OK) {
status.SetToFormat(B_TRANSLATE("Writing audio track: %" B_PRId32 data.SetToFormat("%" B_PRId32 "%%", currPercent);
"%% complete"), currPercent);
} }
status.SetToFormat(B_TRANSLATE("Writing audio track: %s complete"), data.String()); status.SetToFormat(B_TRANSLATE("Writing audio track: %s complete"), data.String());

View File

@ -497,7 +497,7 @@ MediaConverterWindow::MessageReceived(BMessage* message)
double percentValue = value / 100.0; double percentValue = value / 100.0;
if (fNumberFormat.FormatPercent(data, percentValue) != B_OK) 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()); buffer.SetToFormat(B_TRANSLATE("Video quality: %s"), data.String());
fVideoQualitySlider->SetLabel(buffer.String()); fVideoQualitySlider->SetLabel(buffer.String());
@ -514,7 +514,7 @@ MediaConverterWindow::MessageReceived(BMessage* message)
double percentValue = value / 100.0; double percentValue = value / 100.0;
if (fNumberFormat.FormatPercent(data, percentValue) != B_OK) 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()); buffer.SetToFormat(B_TRANSLATE("Audio quality: %s"), data.String());
fAudioQualitySlider->SetLabel(buffer.String()); fAudioQualitySlider->SetLabel(buffer.String());
@ -940,7 +940,7 @@ MediaConverterWindow::_UpdateLabels()
double percentValue = fVideoQuality / 100.0; double percentValue = fVideoQuality / 100.0;
if (fNumberFormat.FormatPercent(data, percentValue) != B_OK) 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()); buffer.SetToFormat(B_TRANSLATE("Video quality: %s"), data.String());
fVideoQuality = (int)percentValue; fVideoQuality = (int)percentValue;
@ -954,7 +954,7 @@ MediaConverterWindow::_UpdateLabels()
double percentValue = fAudioQuality / 100.0; double percentValue = fAudioQuality / 100.0;
if (fNumberFormat.FormatPercent(data, percentValue) != B_OK) { 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()); buffer.SetToFormat(B_TRANSLATE("Audio quality: %s"), data.String());

View File

@ -183,7 +183,7 @@ ShowImageStatusView::_SetZoomText(float zoom)
BString data; BString data;
if (numberFormat.FormatPercent(data, zoom) != B_OK) if (numberFormat.FormatPercent(data, zoom) != B_OK)
fCellText[kZoomCell].SetToFormat("%.0f%%", zoom * 100); data.SetToFormat("%.0f%%", zoom * 100);
fCellText[kZoomCell] = data; fCellText[kZoomCell] = data;
} }