From 3d2944998d8ee3cc7d3e4c99d7be520df857e21b Mon Sep 17 00:00:00 2001 From: kimci86 Date: Sat, 5 Aug 2023 20:19:37 +0200 Subject: [PATCH] Make Text::getFont return a reference because a the m_font pointer cannot be null. --- include/SFML/Graphics/Text.hpp | 7 +++---- src/SFML/Graphics/Text.cpp | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/include/SFML/Graphics/Text.hpp b/include/SFML/Graphics/Text.hpp index e70bdec4..4ed92e0f 100644 --- a/include/SFML/Graphics/Text.hpp +++ b/include/SFML/Graphics/Text.hpp @@ -283,16 +283,15 @@ public: //////////////////////////////////////////////////////////// /// \brief Get the text's font /// - /// If the text has no font attached, a null pointer is returned. - /// The returned pointer is const, which means that you + /// The returned reference is const, which means that you /// cannot modify the font when you get it from this function. /// - /// \return Pointer to the text's font + /// \return Reference to the text's font /// /// \see setFont /// //////////////////////////////////////////////////////////// - const Font* getFont() const; + const Font& getFont() const; //////////////////////////////////////////////////////////// /// \brief Get the character size diff --git a/src/SFML/Graphics/Text.cpp b/src/SFML/Graphics/Text.cpp index aedebddb..79c55c5b 100644 --- a/src/SFML/Graphics/Text.cpp +++ b/src/SFML/Graphics/Text.cpp @@ -241,9 +241,9 @@ const String& Text::getString() const //////////////////////////////////////////////////////////// -const Font* Text::getFont() const +const Font& Text::getFont() const { - return m_font; + return *m_font; }