[PATCH 19/19] tablet-shell: fix crash when trash image is unavailable.

ning.tang at intel.com ning.tang at intel.com
Mon Sep 24 19:40:04 PDT 2012


From: Ning Tang <ning.tang at intel.com>

Use 256 for default trash image size.

Signed-off-by: Ning Tang <ning.tang at intel.com>
---
 clients/tablet-shell.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c
index f5dec79..0e48fa8 100644
--- a/clients/tablet-shell.c
+++ b/clients/tablet-shell.c
@@ -563,21 +563,25 @@ homescreen_create(struct tablet *tablet)
 
 static void trash_set_allocation(struct rectangle allocation)
 {
+	trash_surface = NULL;
 	if (key_trash_image) {
 		if (!trash_surface) {
 			trash_surface = load_cairo_surface(key_trash_image);
 		}
-	} else {
-		trash_surface = NULL;
 	}
 	if (!trash_allocation) {
 		trash_allocation = malloc(sizeof *trash_allocation);
 		trash_allocation->x = allocation.width * 0.6;
 		trash_allocation->y = allocation.height * 0.6;
-		trash_allocation->width =
-			cairo_image_surface_get_width(trash_surface);
-		trash_allocation->height =
-			cairo_image_surface_get_height(trash_surface);
+		if (trash_surface != NULL) {
+			trash_allocation->width =
+				cairo_image_surface_get_width(trash_surface);
+			trash_allocation->height =
+				cairo_image_surface_get_height(trash_surface);
+		} else {
+		    trash_allocation->width = 256;
+		    trash_allocation->height = 256;
+		}
 	}
 }
 
-- 
1.7.12.1



More information about the wayland-devel mailing list