core: add a destructor to CHyprOpenglImpl and avoid wl_container_of undefined behaviour (#7101)
* protocols: avoid undefined behaviour in C macro to safely use wl_container_of with a class the class has to be no virtual functions, no inheritance, and uniform access control (e.g all public) work around this by putting this into a destroywrapper struct. * opengl: clean memory on destruction add a destructor and free the allocated memory and close the fd
This commit is contained in:
parent
60b663e276
commit
9c38b0fdbe
6 changed files with 47 additions and 12 deletions
|
|
@ -11,6 +11,12 @@
|
|||
|
||||
#define PROTO NProtocols
|
||||
|
||||
class IWaylandProtocol;
|
||||
struct IWaylandProtocolDestroyWrapper {
|
||||
wl_listener listener;
|
||||
IWaylandProtocol* parent = nullptr;
|
||||
};
|
||||
|
||||
class IWaylandProtocol {
|
||||
public:
|
||||
IWaylandProtocol(const wl_interface* iface, const int& ver, const std::string& name);
|
||||
|
|
@ -26,7 +32,7 @@ class IWaylandProtocol {
|
|||
Debug::log(level, std::format("[{}] ", m_szName) + std::vformat(fmt.get(), std::make_format_args(args...)));
|
||||
};
|
||||
|
||||
wl_listener m_liDisplayDestroy;
|
||||
IWaylandProtocolDestroyWrapper m_liDisplayDestroy;
|
||||
|
||||
private:
|
||||
std::string m_szName;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue