[clutter] actor: Ensure allocation adjustment is safe against zero sizes
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] actor: Ensure allocation adjustment is safe against zero sizes
- Date: Tue, 19 May 2015 14:27:51 +0000 (UTC)
commit e72a1a44e6e339c55acecba67e2f99412982b832
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri May 15 12:34:53 2015 +0100
actor: Ensure allocation adjustment is safe against zero sizes
We already copy with negative end results, but there's no point in doing
the work in the first place.
clutter/clutter-actor.c | 30 ++++++++++++++++++++++++++----
1 files changed, 26 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c
index 2032567..cffc61b 100644
--- a/clutter/clutter-actor.c
+++ b/clutter/clutter-actor.c
@@ -9203,10 +9203,25 @@ adjust_for_margin (float margin_start,
float *allocated_start,
float *allocated_end)
{
- *minimum_size -= (margin_start + margin_end);
- *natural_size -= (margin_start + margin_end);
- *allocated_start += margin_start;
- *allocated_end -= margin_end;
+ float min_size = *minimum_size;
+ float nat_size = *natural_size;
+ float start = *allocated_start;
+ float end = *allocated_end;
+
+ min_size = MAX (min_size - (margin_start + margin_end), 0);
+ nat_size = MAX (nat_size - (margin_start + margin_end), 0);
+
+ *minimum_size = min_size;
+ *natural_size = nat_size;
+
+ start += margin_start;
+ end -= margin_end;
+
+ if (end - start >= 0)
+ {
+ *allocated_start = start;
+ *allocated_end = end;
+ }
}
static inline void
@@ -9217,6 +9232,9 @@ adjust_for_alignment (ClutterActorAlign alignment,
{
float allocated_size = *allocated_end - *allocated_start;
+ if (allocated_size <= 0.f)
+ return;
+
switch (alignment)
{
case CLUTTER_ACTOR_ALIGN_FILL:
@@ -9805,6 +9823,10 @@ clutter_actor_adjust_allocation (ClutterActor *self,
clutter_actor_box_get_size (allocation, &alloc_width, &alloc_height);
+ /* There's no point in trying to adjust a zero-sized actor */
+ if (alloc_width == 0.f && alloc_height == 0.f)
+ return;
+
/* we want to hit the cache, so we use the public API */
req_mode = clutter_actor_get_request_mode (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]