From 263cb161dab86d518ac1cb52cfb38a2376bafad7 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Sat, 6 Jul 2024 14:57:27 +0200 Subject: [PATCH] allocator: add missing virtual destructor (#3) add missing virtual destructor to base class and free gbm device on destruction of CGBMAllocator --- include/aquamarine/allocator/Allocator.hpp | 1 + include/aquamarine/allocator/GBM.hpp | 1 + src/allocator/GBM.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/include/aquamarine/allocator/Allocator.hpp b/include/aquamarine/allocator/Allocator.hpp index 7567dff..975f348 100644 --- a/include/aquamarine/allocator/Allocator.hpp +++ b/include/aquamarine/allocator/Allocator.hpp @@ -16,6 +16,7 @@ namespace Aquamarine { class IAllocator { public: + virtual ~IAllocator() = default; virtual Hyprutils::Memory::CSharedPointer acquire(const SAllocatorBufferParams& params, Hyprutils::Memory::CSharedPointer swapchain) = 0; virtual Hyprutils::Memory::CSharedPointer getBackend() = 0; }; diff --git a/include/aquamarine/allocator/GBM.hpp b/include/aquamarine/allocator/GBM.hpp index 40b682b..3d4b416 100644 --- a/include/aquamarine/allocator/GBM.hpp +++ b/include/aquamarine/allocator/GBM.hpp @@ -35,6 +35,7 @@ namespace Aquamarine { class CGBMAllocator : public IAllocator { public: + ~CGBMAllocator(); static Hyprutils::Memory::CSharedPointer create(int drmfd_, Hyprutils::Memory::CWeakPointer backend_); virtual Hyprutils::Memory::CSharedPointer acquire(const SAllocatorBufferParams& params, Hyprutils::Memory::CSharedPointer swapchain_); diff --git a/src/allocator/GBM.cpp b/src/allocator/GBM.cpp index 7c93c5e..b533e9b 100644 --- a/src/allocator/GBM.cpp +++ b/src/allocator/GBM.cpp @@ -183,6 +183,11 @@ SDMABUFAttrs Aquamarine::CGBMBuffer::dmabuf() { return attrs; } +CGBMAllocator::~CGBMAllocator() { + if (gbmDevice) + gbm_device_destroy(gbmDevice); +} + SP Aquamarine::CGBMAllocator::create(int drmfd_, Hyprutils::Memory::CWeakPointer backend_) { uint64_t capabilities = 0; if (drmGetCap(drmfd_, DRM_CAP_PRIME, &capabilities) || !(capabilities & DRM_PRIME_CAP_EXPORT)) {