From 09d6409644116c41c54cbff0bd5fcb70cf1bc990 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 6 May 2016 15:02:00 +0100 Subject: [PATCH] Refactored some demo code to avoid a problem when using String::formatted when Strings are UTF-32 --- examples/audio plugin demo/Source/PluginEditor.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/audio plugin demo/Source/PluginEditor.cpp b/examples/audio plugin demo/Source/PluginEditor.cpp index 091d5aa781..107bd2e6d6 100644 --- a/examples/audio plugin demo/Source/PluginEditor.cpp +++ b/examples/audio plugin demo/Source/PluginEditor.cpp @@ -136,14 +136,14 @@ void JuceDemoPluginAudioProcessorEditor::timerCallback() // quick-and-dirty function to format a timecode string static String timeToTimecodeString (double seconds) { - const int millisecs = roundToInt (std::abs (seconds * 1000.0)); + const int millisecs = roundToInt (seconds * 1000.0); + const int absMillisecs = std::abs (millisecs); - return String::formatted ("%s%02d:%02d:%02d.%03d", - seconds < 0 ? "-" : "", + return String::formatted ("%02d:%02d:%02d.%03d", millisecs / 360000, - (millisecs / 60000) % 60, - (millisecs / 1000) % 60, - millisecs % 1000); + (absMillisecs / 60000) % 60, + (absMillisecs / 1000) % 60, + absMillisecs % 1000); } // quick-and-dirty function to format a bars/beats string