diff --git a/plugins/platforms/drm/drm_object.cpp b/plugins/platforms/drm/drm_object.cpp index d2b7bb0d90..1932bf76e8 100644 --- a/plugins/platforms/drm/drm_object.cpp +++ b/plugins/platforms/drm/drm_object.cpp @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ #include "drm_object.h" +#include "drm_pointer.h" #include "logging.h" @@ -49,16 +50,16 @@ void DrmObject::setPropertyNames(QVector &&vector) void DrmObject::initProp(int n, drmModeObjectProperties *properties, QVector enumNames) { for (unsigned int i = 0; i < properties->count_props; ++i) { - drmModePropertyRes *prop = drmModeGetProperty(fd(), properties->props[i]); + ScopedDrmPointer prop( + drmModeGetProperty(fd(), properties->props[i])); if (!prop) { continue; } if (prop->name == m_propsNames[n]) { qCDebug(KWIN_DRM).nospace() << m_id << ": " << prop->name << "' (id " << prop->prop_id << "): " << properties->prop_values[i]; - m_props[n] = new Property(prop, properties->prop_values[i], enumNames); + m_props[n] = new Property(prop.data(), properties->prop_values[i], enumNames); } - drmModeFreeProperty(prop); } } diff --git a/plugins/platforms/drm/drm_object_connector.cpp b/plugins/platforms/drm/drm_object_connector.cpp index 30b6e584ac..27acff4310 100644 --- a/plugins/platforms/drm/drm_object_connector.cpp +++ b/plugins/platforms/drm/drm_object_connector.cpp @@ -54,7 +54,8 @@ bool DrmConnector::initProps() QByteArrayLiteral("CRTC_ID"), }); - drmModeObjectProperties *properties = drmModeObjectGetProperties(fd(), m_id, DRM_MODE_OBJECT_CONNECTOR); + ScopedDrmPointer properties( + drmModeObjectGetProperties(fd(), m_id, DRM_MODE_OBJECT_CONNECTOR)); if (!properties) { qCWarning(KWIN_DRM) << "Failed to get properties for connector " << m_id ; return false; @@ -62,9 +63,9 @@ bool DrmConnector::initProps() int propCount = int(PropertyIndex::Count); for (int j = 0; j < propCount; ++j) { - initProp(j, properties); + initProp(j, properties.data()); } - drmModeFreeObjectProperties(properties); + return true; } diff --git a/plugins/platforms/drm/drm_object_crtc.cpp b/plugins/platforms/drm/drm_object_crtc.cpp index 85f2e654e7..341d80a074 100644 --- a/plugins/platforms/drm/drm_object_crtc.cpp +++ b/plugins/platforms/drm/drm_object_crtc.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . #include "drm_backend.h" #include "drm_output.h" #include "drm_buffer.h" +#include "drm_pointer.h" #include "logging.h" #include @@ -59,7 +60,8 @@ bool DrmCrtc::initProps() QByteArrayLiteral("ACTIVE"), }); - drmModeObjectProperties *properties = drmModeObjectGetProperties(fd(), m_id, DRM_MODE_OBJECT_CRTC); + ScopedDrmPointer properties( + drmModeObjectGetProperties(fd(), m_id, DRM_MODE_OBJECT_CRTC)); if (!properties) { qCWarning(KWIN_DRM) << "Failed to get properties for crtc " << m_id ; return false; @@ -67,9 +69,9 @@ bool DrmCrtc::initProps() int propCount = int(PropertyIndex::Count); for (int j = 0; j < propCount; ++j) { - initProp(j, properties); + initProp(j, properties.data()); } - drmModeFreeObjectProperties(properties); + return true; } diff --git a/plugins/platforms/drm/drm_object_plane.cpp b/plugins/platforms/drm/drm_object_plane.cpp index 929d27d727..19d8abaa9d 100644 --- a/plugins/platforms/drm/drm_object_plane.cpp +++ b/plugins/platforms/drm/drm_object_plane.cpp @@ -92,7 +92,8 @@ bool DrmPlane::initProps() QByteArrayLiteral("reflect-y") }; - drmModeObjectProperties *properties = drmModeObjectGetProperties(fd(), m_id, DRM_MODE_OBJECT_PLANE); + ScopedDrmPointer properties( + drmModeObjectGetProperties(fd(), m_id, DRM_MODE_OBJECT_PLANE)); if (!properties){ qCWarning(KWIN_DRM) << "Failed to get properties for plane " << m_id ; return false; @@ -101,9 +102,9 @@ bool DrmPlane::initProps() int propCount = int(PropertyIndex::Count); for (int j = 0; j < propCount; ++j) { if (j == int(PropertyIndex::Type)) { - initProp(j, properties, typeNames); + initProp(j, properties.data(), typeNames); } else if (j == int(PropertyIndex::Rotation)) { - initProp(j, properties, rotationNames); + initProp(j, properties.data(), rotationNames); m_supportedTransformations = Transformations(); auto testTransform = [j, this] (uint64_t value, Transformation t) { if (propHasEnum(j, value)) { @@ -118,11 +119,10 @@ bool DrmPlane::initProps() testTransform(5, Transformation::ReflectY); qCDebug(KWIN_DRM) << "Supported Transformations: " << m_supportedTransformations << " on plane " << m_id; } else { - initProp(j, properties); + initProp(j, properties.data()); } } - drmModeFreeObjectProperties(properties); return true; }