mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 19:26:00 +01:00
core: free more memory on destruction (#6348)
* pointermgr: add destructor to state and free buf if the pointer has a buffer set it wont be freed upon destruction, make asan more happy by adding a destructor and wlr_buf_unlock it on exit. * cursormgr: free the animation timer event source properly free the animation timer event source on destruction. * compositor: free the critsig event source on exit properly free the critical signal event source on exit. * popup: clang format style clang format.
This commit is contained in:
parent
c95845b148
commit
af5f24929d
5 changed files with 21 additions and 9 deletions
|
@ -147,7 +147,7 @@ void CCompositor::initServer() {
|
||||||
m_sWLEventLoop = wl_display_get_event_loop(m_sWLDisplay);
|
m_sWLEventLoop = wl_display_get_event_loop(m_sWLDisplay);
|
||||||
|
|
||||||
// register crit signal handler
|
// register crit signal handler
|
||||||
wl_event_loop_add_signal(m_sWLEventLoop, SIGTERM, handleCritSignal, nullptr);
|
m_critSigSource = wl_event_loop_add_signal(m_sWLEventLoop, SIGTERM, handleCritSignal, nullptr);
|
||||||
|
|
||||||
if (!envEnabled("HYPRLAND_NO_CRASHREPORTER")) {
|
if (!envEnabled("HYPRLAND_NO_CRASHREPORTER")) {
|
||||||
signal(SIGSEGV, handleUnrecoverableSignal);
|
signal(SIGSEGV, handleUnrecoverableSignal);
|
||||||
|
@ -373,6 +373,9 @@ void CCompositor::cleanup() {
|
||||||
if (m_sWLRBackend)
|
if (m_sWLRBackend)
|
||||||
wlr_backend_destroy(m_sWLRBackend);
|
wlr_backend_destroy(m_sWLRBackend);
|
||||||
|
|
||||||
|
if (m_critSigSource)
|
||||||
|
wl_event_source_remove(m_critSigSource);
|
||||||
|
|
||||||
wl_display_terminate(m_sWLDisplay);
|
wl_display_terminate(m_sWLDisplay);
|
||||||
m_sWLDisplay = nullptr;
|
m_sWLDisplay = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -178,14 +178,15 @@ class CCompositor {
|
||||||
std::string explicitConfigPath;
|
std::string explicitConfigPath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initAllSignals();
|
void initAllSignals();
|
||||||
void removeAllSignals();
|
void removeAllSignals();
|
||||||
void cleanEnvironment();
|
void cleanEnvironment();
|
||||||
void setRandomSplash();
|
void setRandomSplash();
|
||||||
void initManagers(eManagersInitStage stage);
|
void initManagers(eManagersInitStage stage);
|
||||||
void prepareFallbackOutput();
|
void prepareFallbackOutput();
|
||||||
|
|
||||||
uint64_t m_iHyprlandPID = 0;
|
uint64_t m_iHyprlandPID = 0;
|
||||||
|
wl_event_source* m_critSigSource = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CCompositor> g_pCompositor;
|
inline std::unique_ptr<CCompositor> g_pCompositor;
|
||||||
|
|
|
@ -136,7 +136,7 @@ void CPopup::onCommit(bool ignoreSiblings) {
|
||||||
onDestroy();
|
onDestroy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pResource->surface->initialCommit) {
|
if (m_pResource->surface->initialCommit) {
|
||||||
m_pResource->surface->scheduleConfigure();
|
m_pResource->surface->scheduleConfigure();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -58,6 +58,9 @@ CCursorManager::CCursorManager() {
|
||||||
CCursorManager::~CCursorManager() {
|
CCursorManager::~CCursorManager() {
|
||||||
if (m_pWLRXCursorMgr)
|
if (m_pWLRXCursorMgr)
|
||||||
wlr_xcursor_manager_destroy(m_pWLRXCursorMgr);
|
wlr_xcursor_manager_destroy(m_pWLRXCursorMgr);
|
||||||
|
|
||||||
|
if (m_pAnimationTimer)
|
||||||
|
wl_event_source_remove(m_pAnimationTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCursorManager::dropBufferRef(CCursorManager::CCursorBuffer* ref) {
|
void CCursorManager::dropBufferRef(CCursorManager::CCursorBuffer* ref) {
|
||||||
|
|
|
@ -146,6 +146,11 @@ class CPointerManager {
|
||||||
|
|
||||||
struct SMonitorPointerState {
|
struct SMonitorPointerState {
|
||||||
SMonitorPointerState(SP<CMonitor> m) : monitor(m) {}
|
SMonitorPointerState(SP<CMonitor> m) : monitor(m) {}
|
||||||
|
~SMonitorPointerState() {
|
||||||
|
if (cursorFrontBuffer)
|
||||||
|
wlr_buffer_unlock(cursorFrontBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
WP<CMonitor> monitor;
|
WP<CMonitor> monitor;
|
||||||
|
|
||||||
int softwareLocks = 0;
|
int softwareLocks = 0;
|
||||||
|
|
Loading…
Reference in a new issue