From abc04ec132b242c4f78219db2d8f0a0c5c0f942c Mon Sep 17 00:00:00 2001 From: OmniaX-Dev Date: Fri, 8 May 2026 00:58:46 +0200 Subject: [PATCH] Actually fixed pointer conversion bug --- src/ogfx/render/BasicRenderer.cpp | 2 +- src/ostd/string/String.cpp | 26 +++++++++++++------------- src/ostd/string/String.hpp | 4 ++-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ogfx/render/BasicRenderer.cpp b/src/ogfx/render/BasicRenderer.cpp index c8b4290..ee49f15 100644 --- a/src/ogfx/render/BasicRenderer.cpp +++ b/src/ogfx/render/BasicRenderer.cpp @@ -248,7 +248,7 @@ namespace ogfx if (!font) font = m_font; auto l_buildCacheKey = [&](void) -> String { - return String("").add(message).add(fontSize).add(font); + return String("").add(message).add(fontSize).addPtr(font); }; String cacheKey = l_buildCacheKey(); diff --git a/src/ostd/string/String.cpp b/src/ostd/string/String.cpp index 2e0cf75..6afc647 100644 --- a/src/ostd/string/String.cpp +++ b/src/ostd/string/String.cpp @@ -189,6 +189,13 @@ namespace ostd return *this; } + String& String::addPtr(const void* p, const String& prefix) + { + std::stringstream stream; + stream << prefix << std::hex << std::uppercase << reinterpret_cast(p); + return add(stream.str()); + } + String& String::add(const String& se) { m_data += se.cpp_str(); @@ -265,13 +272,6 @@ namespace ostd return add(s); } - String& String::add(const void* p, const String& prefix) - { - std::stringstream stream; - stream << prefix << std::hex << std::uppercase << reinterpret_cast(p); - return add(stream.str()); - } - //New String @@ -372,6 +372,12 @@ namespace ostd return __str.addChar(c); } + String String::new_addPtr(const void* p, const String& prefix) + { + String __str = m_data; + return __str.addPtr(p, prefix); + } + String String::new_add(const String& se) const { String __str = m_data; @@ -438,12 +444,6 @@ namespace ostd return __str.add(f, precision); } - String String::new_add(const void* p, const String& prefix) - { - String __str = m_data; - return __str.add(p, prefix); - } - //Utility diff --git a/src/ostd/string/String.hpp b/src/ostd/string/String.hpp index f427bb7..92f60ef 100644 --- a/src/ostd/string/String.hpp +++ b/src/ostd/string/String.hpp @@ -111,6 +111,7 @@ namespace ostd String& fixedLength(u32 length, char fill_character = ' ', const String& truncate_indicator = "... "); String& addChar(char c); + String& addPtr(const void* p, const String& prefix = "0x"); String& add(const String& se); String& add(u8 i); String& add(i8 i); @@ -122,7 +123,6 @@ namespace ostd String& add(i64 i); String& add(f32 f, u8 precision = 0); String& add(f64 f, u8 precision = 0); - String& add(const void* p, const String& prefix = "0x"); //New String String new_ltrim(void) const; @@ -142,6 +142,7 @@ namespace ostd String new_fixedLength(u32 length, char fill_character = ' ', const String& truncate_indicator = "... ") const; String new_addChar(char c) const; + String new_addPtr(const void* p, const String& prefix = "0x"); String new_add(const String& se) const; String new_add(u8 i) const; String new_add(i8 i) const; @@ -153,7 +154,6 @@ namespace ostd String new_add(i64 i) const; String new_add(f32 f, u8 precision = 0) const; String new_add(f64 f, u8 precision = 0) const; - String new_add(const void* p, const String& prefix = "0x"); //Utility i64 toInt(void) const;