From 38f0e31a484b0e0a7e356140bad303c37c1343c0 Mon Sep 17 00:00:00 2001 From: Flakebi Date: Thu, 5 Feb 2015 02:43:20 +0100 Subject: [PATCH 1/3] Fix clang build, freeing memory too early --- src/modes/linear_world.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 4d884189e..18399da5a 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -350,10 +350,13 @@ void LinearWorld::newLap(unsigned int kart_index) std::string s = StringUtils::timeToString(time_per_lap); - irr::core::stringw m_fastest_lap_message; + // Store the temporary string because clang would mess this up + // (remove the stringw before the wchar_t* is used). + core::stringw css = kart->getName(); + //I18N: as in "fastest lap: 60 seconds by Wilber" - m_fastest_lap_message += _C("fastest_lap", "%s by %s", s.c_str(), - core::stringw(kart->getName())); + irr::core::stringw m_fastest_lap_message = + _C("fastest_lap", "%s by %s", s.c_str(), css.c_str()); m_race_gui->addMessage(m_fastest_lap_message, NULL, 3.0f, video::SColor(255, 255, 255, 255), false); From 31d4c34fbb7819e359cea4ef9e333fb39637125d Mon Sep 17 00:00:00 2001 From: Flakebi Date: Thu, 5 Feb 2015 15:18:57 +0100 Subject: [PATCH 2/3] Improve clang bugfix --- src/modes/linear_world.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 18399da5a..40cfa20b8 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -352,11 +352,11 @@ void LinearWorld::newLap(unsigned int kart_index) // Store the temporary string because clang would mess this up // (remove the stringw before the wchar_t* is used). - core::stringw css = kart->getName(); + core::stringw kartName = kart->getName(); //I18N: as in "fastest lap: 60 seconds by Wilber" irr::core::stringw m_fastest_lap_message = - _C("fastest_lap", "%s by %s", s.c_str(), css.c_str()); + _C("fastest_lap", "%s by %s", s.c_str(), kartName); m_race_gui->addMessage(m_fastest_lap_message, NULL, 3.0f, video::SColor(255, 255, 255, 255), false); From ca2b5335dc291c17d8c0a8653ae3382fcf7d32d5 Mon Sep 17 00:00:00 2001 From: hiker Date: Sun, 8 Feb 2015 22:22:06 +1100 Subject: [PATCH 3/3] Removed hopefully unnecessary string copy. --- src/modes/linear_world.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 78bd96236..d8bd33c07 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -351,11 +351,11 @@ void LinearWorld::newLap(unsigned int kart_index) // Store the temporary string because clang would mess this up // (remove the stringw before the wchar_t* is used). - core::stringw kartName = kart->getName(); + const core::stringw &kart_name = kart->getName(); //I18N: as in "fastest lap: 60 seconds by Wilber" irr::core::stringw m_fastest_lap_message = - _C("fastest_lap", "%s by %s", s.c_str(), kartName); + _C("fastest_lap", "%s by %s", s.c_str(), kart_name); m_race_gui->addMessage(m_fastest_lap_message, NULL, 3.0f, video::SColor(255, 255, 255, 255), false);