From c0bc23f7b2bd6baf7946075197e85ae229a53dea Mon Sep 17 00:00:00 2001 From: Yury Klushin Date: Wed, 14 Feb 2024 01:04:52 +0300 Subject: [PATCH] Fixed: warning about wrong local strong using as constant --- src/audio-sdlmixer.h | 2 +- src/audio.cc | 2 +- src/audio.h | 6 +++--- src/debug.cc | 10 +++++----- src/debug.h | 4 ++-- src/gfx.h | 2 +- src/video-sdl.h | 2 +- src/video.cc | 2 +- src/video.h | 6 +++--- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/audio-sdlmixer.h b/src/audio-sdlmixer.h index ee33ef2c5..5ff4530be 100644 --- a/src/audio-sdlmixer.h +++ b/src/audio-sdlmixer.h @@ -40,7 +40,7 @@ class ExceptionSDLmixer : public ExceptionAudio { explicit ExceptionSDLmixer(const std::string &description); virtual ~ExceptionSDLmixer() {} - virtual std::string get_platform() const { return "SDL_mixer"; } + virtual const std::string get_platform() const { return "SDL_mixer"; } }; class AudioSDL : public Audio, public Audio::VolumeController { diff --git a/src/audio.cc b/src/audio.cc index b746b7419..2a03d0bb9 100644 --- a/src/audio.cc +++ b/src/audio.cc @@ -33,7 +33,7 @@ ExceptionAudio::ExceptionAudio(const std::string &description) : ExceptionAudio::~ExceptionAudio() { } -std::string +const std::string ExceptionAudio::get_description() const { return "[" + get_system() + ":" + get_platform() + "] " + description.c_str(); } diff --git a/src/audio.h b/src/audio.h index 1f059326c..850e94baa 100644 --- a/src/audio.h +++ b/src/audio.h @@ -34,9 +34,9 @@ class ExceptionAudio : public ExceptionFreeserf { explicit ExceptionAudio(const std::string &description); virtual ~ExceptionAudio(); - virtual std::string get_description() const; - virtual std::string get_platform() const { return "Abstract"; } - virtual std::string get_system() const { return "audio"; } + virtual const std::string get_description() const; + virtual const std::string get_platform() const { return "Abstract"; } + virtual const std::string get_system() const { return "audio"; } }; class Audio { diff --git a/src/debug.cc b/src/debug.cc index cf74f287b..577642f85 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -21,8 +21,8 @@ #include "src/debug.h" -ExceptionFreeserf::ExceptionFreeserf(const std::string &description_) throw() - : description(description_) { +ExceptionFreeserf::ExceptionFreeserf(const std::string &description_) throw() { + description = "[" + get_system() + "] " + description_; } ExceptionFreeserf::~ExceptionFreeserf() { @@ -30,10 +30,10 @@ ExceptionFreeserf::~ExceptionFreeserf() { const char* ExceptionFreeserf::what() const throw() { - return get_description().c_str(); + return description.c_str(); } -std::string +const std::string ExceptionFreeserf::get_description() const { - return "[" + get_system() + "] " + description; + return description; } diff --git a/src/debug.h b/src/debug.h index 23c63b43b..00d16bfd5 100644 --- a/src/debug.h +++ b/src/debug.h @@ -35,8 +35,8 @@ class ExceptionFreeserf : public std::exception { virtual ~ExceptionFreeserf(); virtual const char* what() const throw(); - virtual std::string get_description() const; - virtual std::string get_system() const { return "Unspecified"; } + virtual const std::string get_description() const; + virtual const std::string get_system() const { return "Unspecified"; } }; #ifndef NDEBUG diff --git a/src/gfx.h b/src/gfx.h index 267267ff6..188dd1bda 100644 --- a/src/gfx.h +++ b/src/gfx.h @@ -35,7 +35,7 @@ class ExceptionGFX : public ExceptionFreeserf { explicit ExceptionGFX(const std::string &description); virtual ~ExceptionGFX(); - virtual std::string get_system() const { return "graphics"; } + virtual const std::string get_system() const { return "graphics"; } }; class Color { diff --git a/src/video-sdl.h b/src/video-sdl.h index 98cb71e2a..f3b856731 100644 --- a/src/video-sdl.h +++ b/src/video-sdl.h @@ -53,7 +53,7 @@ class ExceptionSDL : public ExceptionVideo { explicit ExceptionSDL(const std::string &description) throw(); virtual ~ExceptionSDL() {} - virtual std::string get_platform() const { return "SDL"; } + virtual const std::string get_platform() const { return "SDL"; } }; class VideoSDL : public Video { diff --git a/src/video.cc b/src/video.cc index f654af6d5..cf270adc0 100644 --- a/src/video.cc +++ b/src/video.cc @@ -30,7 +30,7 @@ ExceptionVideo::ExceptionVideo(const std::string &description) : ExceptionVideo::~ExceptionVideo() { } -std::string +const std::string ExceptionVideo::get_description() const { return "[" + get_system() + ":" + get_platform() + "] " + description.c_str(); } diff --git a/src/video.h b/src/video.h index ba2396f81..98b3e3789 100644 --- a/src/video.h +++ b/src/video.h @@ -32,9 +32,9 @@ class ExceptionVideo : public ExceptionFreeserf { explicit ExceptionVideo(const std::string &description); virtual ~ExceptionVideo(); - virtual std::string get_description() const; - virtual std::string get_platform() const { return "Abstract"; } - virtual std::string get_system() const { return "video"; } + virtual const std::string get_description() const; + virtual const std::string get_platform() const { return "Abstract"; } + virtual const std::string get_system() const { return "video"; } }; class Video {