[cluttermm] Rect: Fix some memory-management problems.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cluttermm] Rect: Fix some memory-management problems.
- Date: Wed, 26 Mar 2014 09:31:40 +0000 (UTC)
commit 9037c453d8879f61a987625e12ec127ca4e569a3
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Mar 26 10:27:56 2014 +0100
Rect: Fix some memory-management problems.
clutter/src/color.ccg | 7 +++++++
clutter/src/color.hg | 15 +++++++--------
clutter/src/types.ccg | 17 ++++++++++-------
codegen/m4/convert_clutter.m4 | 3 +--
4 files changed, 25 insertions(+), 17 deletions(-)
---
diff --git a/clutter/src/color.ccg b/clutter/src/color.ccg
index b916ba7..26e861e 100644
--- a/clutter/src/color.ccg
+++ b/clutter/src/color.ccg
@@ -102,6 +102,13 @@ void Color::lighten()
clutter_color_lighten(this->gobj(), this->gobj());
}
+Color Color::interpolate(const Color& final, double progress) const
+{
+ Color result;
+ clutter_color_interpolate(const_cast<ClutterColor*>(gobj()), final.gobj(), progress, result.gobj());
+ return result;
+}
+
Color operator+(const Color& color1, const Color& color2)
{
Color result;
diff --git a/clutter/src/color.hg b/clutter/src/color.hg
index e6b3369..3683766 100644
--- a/clutter/src/color.hg
+++ b/clutter/src/color.hg
@@ -42,6 +42,7 @@ public:
// or have an odd signature that takes a guint8 as the last parameter
_CUSTOM_DEFAULT_CTOR
Color();
+
/** Create a new Color object by specifying its value in RGB(A)
*/
Color(guint8 red, guint8 green, guint8 blue, guint8 alpha=255);
@@ -52,8 +53,6 @@ public:
// TODO: this could fail, just return a 'default' color or throw an exception?
explicit Color(const Glib::ustring& color);
-#m4 _CONVERSION(`StaticColor',`ClutterStaticColor',`($2)($3)')
-#m4 _INITIALIZATION(`Clutter::StaticColor',`ClutterStaticColor',`($2)($3)')
explicit Color(StaticColor color);
@@ -87,6 +86,7 @@ public:
_WRAP_METHOD_DOCS_ONLY(clutter_color_darken)
void darken();
_IGNORE(clutter_color_darken)
+
_WRAP_METHOD_DOCS_ONLY(clutter_color_lighten)
void lighten();
_IGNORE(clutter_color_lighten)
@@ -95,15 +95,14 @@ public:
void shade(double shade);
_IGNORE(clutter_color_shade)
- #m4 _INITIALIZATION(`Glib::RefPtr<Color>',`ClutterColor',`&($3).gobj()')
- #m4 _INITIALIZATION(`Color&',`ClutterColor',`($2)')
- _WRAP_METHOD(void interpolate(const Color& final, double progress, Color& result),
clutter_color_interpolate)
+ /** Interpolates between this initial color and a @a final color.
+ * @param The interpolation progress.
+ */
+ Color interpolate(const Color& final, double progress) const;
+ _IGNORE(clutter_color_interpolate)
- //TODO IM: ParamSpec. 'nuff said. Not wrapped until I have to.
_IGNORE(clutter_param_spec_color, clutter_value_set_color, clutter_value_get_color)
- // provide accessors/mutators to modify the individual members like you could
- // do in C by directly modifying the struct members
_MEMBER_GET(red, red, guint8, guint8)
_MEMBER_SET(red, red, guint8, guint8)
_MEMBER_GET(green, green, guint8, guint8)
diff --git a/clutter/src/types.ccg b/clutter/src/types.ccg
index 4f200d3..ccf9890 100644
--- a/clutter/src/types.ccg
+++ b/clutter/src/types.ccg
@@ -97,9 +97,8 @@ void Geometry::set_size(guint width, guint height)
Rect::Rect(float x, float y, float width, float height)
{
- ClutterRect* rect = clutter_rect_alloc();
- rect =clutter_rect_init(rect, x, y, width, height);
- gobject_ = clutter_rect_copy(rect);
+ gobject_ = clutter_rect_alloc();
+ clutter_rect_init(gobject_, x, y, width, height);;
}
static gboolean cluttermm_rect_equals(const ClutterRect* a, const ClutterRect* b)
@@ -109,16 +108,20 @@ static gboolean cluttermm_rect_equals(const ClutterRect* a, const ClutterRect* b
Point Rect::get_centre() const
{
- ClutterPoint* p = 0;
+ ClutterPoint* p = clutter_point_alloc();
clutter_rect_get_center(const_cast<ClutterRect*>(gobj()), p);
- return Glib::wrap(p);
+ const Point result = Glib::wrap(p);
+ clutter_point_free(p);
+ return result;
}
Rect Rect::rect_union(const Rect& b) const
{
- ClutterRect* crect = 0;
+ ClutterRect* crect = clutter_rect_alloc();
clutter_rect_union(const_cast<ClutterRect*>(gobj()), const_cast<ClutterRect*>(b.gobj()), crect);
- return Glib::wrap(crect);
+ const Rect result = Glib::wrap(crect);
+ clutter_rect_free(crect);
+ return result;
}
diff --git a/codegen/m4/convert_clutter.m4 b/codegen/m4/convert_clutter.m4
index e294447..955e156 100644
--- a/codegen/m4/convert_clutter.m4
+++ b/codegen/m4/convert_clutter.m4
@@ -38,8 +38,6 @@ _CONVERSION(`Glib::RefPtr<ChildMeta>',`ClutterChildMeta*',__CONVERT_REFPTR_TO_P)
_CONVERSION(`ClutterChildMeta*',`Glib::RefPtr<ChildMeta>',`Glib::wrap($3)')
_CONVERSION(`ClutterChildMeta*',`Glib::RefPtr<const ChildMeta>',`Glib::wrap($3)')
-_CONVERSION(`Color',`ClutterColor*',`($3).gobj()')
-_CONVERSION(`Color&',`ClutterColor*',`($3).gobj()')
_CONVERSION(`const Color&',`ClutterColor*',`($3).gobj()')
_CONVERSION(`const Color&',`const ClutterColor*',`($3).gobj()')
@@ -171,6 +169,7 @@ _CONV_ENUM(Clutter,RequestMode)
_CONV_ENUM(Clutter,RotateAxis)
_CONV_ENUM(Clutter,RotateDirection)
_CONV_ENUM(Clutter,ShaderType)
+_CONV_ENUM(Clutter,StaticColor)
_CONV_ENUM(Clutter,TextDirection)
_CONV_ENUM(Clutter,TextureFlags)
_CONV_ENUM(Clutter,TextureQuality)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]