fix: prevent UITheme memory leak on theme reload (#975)
## Summary - `UITheme::currentTheme` was a raw owning pointer with no destructor, causing a heap leak every time `setTheme()` was called (e.g. on theme change via settings reload) ## Additional Context - Replaced `const BaseTheme*` with `std::unique_ptr<BaseTheme>` so the previous theme object is automatically deleted on reassignment - Added `<memory>` include to `UITheme.h`; allocations updated to `std::make_unique<>` in `UITheme.cpp` --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**NO**_ (identified by claude though) --------- Co-authored-by: Dave Allie <dave@daveallie.com>
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include "CrossPointSettings.h"
|
||||
#include "components/themes/BaseTheme.h"
|
||||
|
||||
class MappedInputManager;
|
||||
|
||||
class UITheme {
|
||||
// Static instance
|
||||
static UITheme instance;
|
||||
@@ -26,7 +25,7 @@ class UITheme {
|
||||
|
||||
private:
|
||||
const ThemeMetrics* currentMetrics;
|
||||
const BaseTheme* currentTheme;
|
||||
std::unique_ptr<BaseTheme> currentTheme;
|
||||
};
|
||||
|
||||
// Helper macro to access current theme
|
||||
|
||||
Reference in New Issue
Block a user