Improve memory safety
Fixed a case where after the splash screen was over the RenderTargets & Texture created in it weren't deleted.
This commit is contained in:
@@ -14,6 +14,8 @@ namespace CaveGame::Client
|
||||
{
|
||||
public:
|
||||
Scene();
|
||||
virtual ~Scene() = default;
|
||||
|
||||
/// This function is called by the SceneManager when a scene is changed.
|
||||
/// @note Make sure to call this base when overriding in derived Scene classes.
|
||||
virtual void Load();
|
||||
|
@@ -11,23 +11,11 @@ namespace CaveGame::Client
|
||||
/// The splash screen is responsible for displaying the Redacted Software Logo and then showing the loading bar.
|
||||
class Splash : public Scene
|
||||
{
|
||||
public:
|
||||
Splash();
|
||||
//~Splash();
|
||||
void Draw() override;
|
||||
void Update(float elapsed) override;
|
||||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
//void PassFont(JGL::Font passed);
|
||||
|
||||
bool SplashComplete() const;
|
||||
private:
|
||||
float splash_timer = 1.5f;
|
||||
float load_percent = 0.f;
|
||||
JGL::Texture* splash; // TODO: RAII on this
|
||||
//JGL::Font font; // TODO: RAII on this
|
||||
float increment = 0;
|
||||
|
||||
std::array<JGL::RenderTarget*, 16> column_textures{};
|
||||
|
||||
@@ -41,5 +29,16 @@ namespace CaveGame::Client
|
||||
|
||||
void DrawMatrix();
|
||||
void DrawProgressBar();
|
||||
public:
|
||||
Splash();
|
||||
~Splash() override;
|
||||
void Draw() override;
|
||||
void Update(float elapsed) override;
|
||||
void Load() override;
|
||||
void Unload() override;
|
||||
|
||||
//void PassFont(JGL::Font passed);
|
||||
|
||||
[[nodiscard]] bool SplashComplete() const;
|
||||
};
|
||||
}
|
@@ -135,10 +135,17 @@ void CaveGame::Client::Splash::Load() {
|
||||
}
|
||||
|
||||
void CaveGame::Client::Splash::Unload() {
|
||||
Scene::Unload();
|
||||
for (auto* r : column_textures)
|
||||
delete r;
|
||||
delete splash;
|
||||
|
||||
Scene::Unload();
|
||||
}
|
||||
|
||||
bool CaveGame::Client::Splash::SplashComplete() const {
|
||||
return splash_timer < 0;
|
||||
}
|
||||
|
||||
CaveGame::Client::Splash::~Splash() {
|
||||
Splash::Unload();
|
||||
}
|
||||
|
Reference in New Issue
Block a user