From 33363908c1495443fc1f7c41fd39d9f0833cf6e9 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Mon, 11 Nov 2013 10:04:33 +0100 Subject: [PATCH] ensures xcb_reply_t deallocation using QScopedPointer --- clients/oxygen/config/oxygendetectwidget.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/clients/oxygen/config/oxygendetectwidget.cpp b/clients/oxygen/config/oxygendetectwidget.cpp index e93dbda27b..59cdb368ec 100644 --- a/clients/oxygen/config/oxygendetectwidget.cpp +++ b/clients/oxygen/config/oxygendetectwidget.cpp @@ -30,12 +30,12 @@ #include "oxygendetectwidget.h" #include "oxygendetectwidget.moc" -#include #include #include #include #include #include +#include #include #include @@ -58,10 +58,10 @@ namespace Oxygen // create atom xcb_connection_t* connection( QX11Info::connection() ); - const QString atomName( QLatin1String( "WM_STATE" ) ); + const QString atomName( QStringLiteral( "WM_STATE" ) ); xcb_intern_atom_cookie_t cookie( xcb_intern_atom( connection, false, atomName.size(), qPrintable( atomName ) ) ); - xcb_intern_atom_reply_t* reply( xcb_intern_atom_reply( connection, cookie, 0) ); - if( reply ) _wmStateAtom = reply->atom; + QScopedPointer reply( xcb_intern_atom_reply( connection, cookie, nullptr) ); + _wmStateAtom = reply ? reply->atom : 0; } @@ -151,17 +151,13 @@ namespace Oxygen { // query pointer - xcb_query_pointer_reply_t* pointerReply( 0x0 ); - { - xcb_query_pointer_cookie_t cookie( xcb_query_pointer( connection, parent ) ); - pointerReply = xcb_query_pointer_reply( connection, cookie, 0 ); - } - + xcb_query_pointer_cookie_t pointerCookie( xcb_query_pointer( connection, parent ) ); + QScopedPointer pointerReply( xcb_query_pointer_reply( connection, pointerCookie, nullptr ) ); if( !( pointerReply && pointerReply->child ) ) return 0; const xcb_window_t child( pointerReply->child ); - xcb_get_property_cookie_t cookie( xcb_get_property( connection, 0, child, _wmStateAtom, XCB_GET_PROPERTY_TYPE_ANY, 0, 0) ); - xcb_get_property_reply_t* reply( xcb_get_property_reply( connection, cookie, 0 ) ); + xcb_get_property_cookie_t cookie( xcb_get_property( connection, 0, child, _wmStateAtom, XCB_GET_PROPERTY_TYPE_ANY, 0, 0 ) ); + QScopedPointer reply( xcb_get_property_reply( connection, cookie, nullptr ) ); if( reply && reply->type ) return child; else parent = child;