diff options
| author | vaxerski <vaxry@vaxry.net> | 2024-01-19 16:20:22 +0100 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2024-01-19 16:20:30 +0100 |
| commit | 5eeec8860e2dc8ff80dda26243778b5ecc923ca2 (patch) | |
| tree | e8dd7245da969dfdf2ae1acd07ad9cca0816b7b4 /src/helpers | |
| parent | 9f20a15955697b0f52740c1e0180acdafa071f79 (diff) | |
core: improve cleanup logic
Diffstat (limited to 'src/helpers')
| -rw-r--r-- | src/helpers/MiscFunctions.cpp | 7 | ||||
| -rw-r--r-- | src/helpers/MiscFunctions.hpp | 1 | ||||
| -rw-r--r-- | src/helpers/WLListener.cpp | 6 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index 5eb99bfd..2905ce2b 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -159,6 +159,13 @@ void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, const Debug::log(LOG, "Registered signal for owner {:x}: {:x} -> {:x} (owner: {})", (uintptr_t)pOwner, (uintptr_t)pSignal, (uintptr_t)pListener, ownerString); } +void removeWLSignal(wl_listener* pListener) { + wl_list_remove(&pListener->link); + wl_list_init(&pListener->link); + + Debug::log(LOG, "Removed listener {:x}", (uintptr_t)pListener); +} + void handleNoop(struct wl_listener* listener, void* data) { // Do nothing } diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index 1ccbdc0e..23fc6e5a 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -15,6 +15,7 @@ struct SCallstackFrameInfo { std::string absolutePath(const std::string&, const std::string&); void addWLSignal(wl_signal*, wl_listener*, void* pOwner, const std::string& ownerString); +void removeWLSignal(wl_listener*); std::string escapeJSONStrings(const std::string& str); std::string removeBeginEndSpacesTabs(std::string); bool isNumber(const std::string&, bool allowfloat = false); diff --git a/src/helpers/WLListener.cpp b/src/helpers/WLListener.cpp index 402c999c..f499b929 100644 --- a/src/helpers/WLListener.cpp +++ b/src/helpers/WLListener.cpp @@ -7,13 +7,15 @@ void handleWrapped(wl_listener* listener, void* data) { CHyprWLListener::SWrapper* pWrap = wl_container_of(listener, pWrap, m_sListener); - g_pWatchdog->startWatching(); + if (g_pWatchdog) + g_pWatchdog->startWatching(); try { pWrap->m_pSelf->emit(data); } catch (std::exception& e) { Debug::log(ERR, "Listener {} timed out and was killed by Watchdog!!!", (uintptr_t)listener); } - g_pWatchdog->endWatching(); + if (g_pWatchdog) + g_pWatchdog->endWatching(); } CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner) { |
