summaryrefslogtreecommitdiff
path: root/src/propertywriter.cpp
diff options
context:
space:
mode:
authorSam Spilsbury <smspillaz@gmail.com>2010-10-24 01:03:38 +0800
committerSam Spilsbury <smspillaz@gmail.com>2010-10-24 22:42:07 +0800
commit30bbd683132d12ab9ceadcaf6e955cd2c3d30376 (patch)
treefd5132ed2b93bc0702c3713133064c94619b69fe /src/propertywriter.cpp
parent7043284c7781a18a79bed8253d8509785ac8d766 (diff)
downloadunity-window-decorator-30bbd683132d12ab9ceadcaf6e955cd2c3d30376.tar.gz
unity-window-decorator-30bbd683132d12ab9ceadcaf6e955cd2c3d30376.tar.bz2
Fix some memory leaks (it looks like there are some more in XTextPropertyToStringList too)
Diffstat (limited to 'src/propertywriter.cpp')
-rw-r--r--src/propertywriter.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/propertywriter.cpp b/src/propertywriter.cpp
index 44e7990..ee1bef7 100644
--- a/src/propertywriter.cpp
+++ b/src/propertywriter.cpp
@@ -55,7 +55,7 @@ PropertyWriter::updateProperty (Window id,
int type)
{
int count = 0;
-
+
if (type != XA_STRING)
{
@@ -89,7 +89,7 @@ PropertyWriter::updateProperty (Window id,
char * data[propertyData.size ()];
XTextProperty prop;
bool ok = true;
-
+
foreach (CompOption &o, propertyData)
{
switch (o.type ())
@@ -101,10 +101,10 @@ PropertyWriter::updateProperty (Window id,
data[count] = NULL;
break;
}
-
+
count++;
}
-
+
for (int i = 0; i < count; i++)
{
if (data[i] == NULL)
@@ -112,14 +112,17 @@ PropertyWriter::updateProperty (Window id,
ok = false;
}
}
-
+
if (ok)
{
if (XStringListToTextProperty (data, count, &prop))
+ {
XSetTextProperty (screen->dpy (), id, &prop, mAtom);
+ XFree (prop.value);
+ }
}
}
-
+
return true;
}
@@ -135,8 +138,8 @@ PropertyWriter::readProperty (Window id)
Atom type;
int retval, fmt;
unsigned long nitems, exbyte;
- long int *data;
-
+ long int *data;
+
if (mPropertyValues.empty ())
return mPropertyValues;
@@ -147,7 +150,7 @@ PropertyWriter::readProperty (Window id)
if (retval == Success && !mPropertyValues.empty ())
{
- int count = 0;
+ int count = 0;
if (type == XA_CARDINAL && fmt == 32 &&
nitems == mPropertyValues.size ())
@@ -170,12 +173,12 @@ PropertyWriter::readProperty (Window id)
o.set (tmpVal);
break;
}
-
+
count++;
}
-
+
XFree (data);
-
+
return mPropertyValues;
}
else if (type == XA_STRING && fmt == 8)
@@ -187,30 +190,38 @@ PropertyWriter::readProperty (Window id)
{
int retCount = 0;
char **tData = NULL;
-
+
XTextPropertyToStringList (&tProp, &tData, &retCount);
-
+
if (retCount == (int) mPropertyValues.size ())
{
foreach (CompOption &o, mPropertyValues)
{
CompOption::Value tmpVal;
tmpVal = CompOption::Value (CompString ((char *) tData[count]));
-
+
o.set (tmpVal);
-
+
count++;
}
+ XFree (tData);
+ XFree (data);
+
return mPropertyValues;
}
else
{
+ XFree (tData);
+ XFree (data);
+
return nilValues;
- }
+ }
}
else
{
+ XFree (data);
+
return nilValues;
}
}
@@ -223,6 +234,6 @@ PropertyWriter::readProperty (Window id)
{
return mPropertyValues;
}
-
+
return mPropertyValues;
}