diff options
| author | Tom Englund <tomenglund26@gmail.com> | 2025-09-25 01:44:33 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-25 01:44:33 +0200 |
| commit | 8cce3b98cebd6910a9c94c11a6efb2293d2031bc (patch) | |
| tree | 170990c2f38e0c0e8f6aff30f30dd3bd035c2813 /src/protocols/core/Shm.hpp | |
| parent | 683fc77f80e6ba32cd3cff04fccdc95f7a9308a1 (diff) | |
shm: refactor to UP and correct m_data check (#11820)
use unique pointers and rvalue references where applicable, buffer is
still a shared pointer because CHLBufferReference uses it to hold it
locked.
in CSHMPool destructor add a check for m_data != MAP_FAILED same in
resize, because mmap returns (void *) -1 on failure and that is not
comparable to nullptr. delete default constructor so we dont end up in
weird states with m_data.
Diffstat (limited to 'src/protocols/core/Shm.hpp')
| -rw-r--r-- | src/protocols/core/Shm.hpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/protocols/core/Shm.hpp b/src/protocols/core/Shm.hpp index e504146d..37210398 100644 --- a/src/protocols/core/Shm.hpp +++ b/src/protocols/core/Shm.hpp @@ -20,6 +20,7 @@ class CWLSHMPoolResource; class CSHMPool { public: + CSHMPool() = delete; CSHMPool(Hyprutils::OS::CFileDescriptor fd, size_t size); ~CSHMPool(); @@ -32,7 +33,7 @@ class CSHMPool { class CWLSHMBuffer : public IHLBuffer { public: - CWLSHMBuffer(SP<CWLSHMPoolResource> pool, uint32_t id, int32_t offset, const Vector2D& size, int32_t stride, uint32_t fmt); + CWLSHMBuffer(WP<CWLSHMPoolResource> pool, uint32_t id, int32_t offset, const Vector2D& size, int32_t stride, uint32_t fmt); virtual ~CWLSHMBuffer(); virtual Aquamarine::eBufferCapability caps(); @@ -58,7 +59,7 @@ class CWLSHMBuffer : public IHLBuffer { class CWLSHMPoolResource { public: - CWLSHMPoolResource(SP<CWlShmPool> resource_, Hyprutils::OS::CFileDescriptor fd, size_t size); + CWLSHMPoolResource(UP<CWlShmPool>&& resource_, Hyprutils::OS::CFileDescriptor fd, size_t size); bool good(); @@ -67,19 +68,19 @@ class CWLSHMPoolResource { WP<CWLSHMPoolResource> m_self; private: - SP<CWlShmPool> m_resource; + UP<CWlShmPool> m_resource; friend class CWLSHMBuffer; }; class CWLSHMResource { public: - CWLSHMResource(SP<CWlShm> resource_); + CWLSHMResource(UP<CWlShm>&& resource_); bool good(); private: - SP<CWlShm> m_resource; + UP<CWlShm> m_resource; }; class CWLSHMProtocol : public IWaylandProtocol { @@ -94,8 +95,8 @@ class CWLSHMProtocol : public IWaylandProtocol { void destroyResource(CWLSHMBuffer* resource); // - std::vector<SP<CWLSHMResource>> m_managers; - std::vector<SP<CWLSHMPoolResource>> m_pools; + std::vector<UP<CWLSHMResource>> m_managers; + std::vector<UP<CWLSHMPoolResource>> m_pools; std::vector<SP<CWLSHMBuffer>> m_buffers; // |
