Branch: master

7fa44e6a 2014-07-08 09:16:22 Timothy Pearson
Fix abort on startup due to oversized tray icon creation when icon widget has not yet been shown
M src/tdepowersave.cpp
diff --git a/src/tdepowersave.cpp b/src/tdepowersave.cpp
index 50413f8..6779aae 100644
--- a/src/tdepowersave.cpp
+++ b/src/tdepowersave.cpp
@@ -369,10 +369,11 @@
 	if ((pixmap_name_tmp != pixmap_name) || (forceReload)) {
 		pixmap_name = pixmap_name_tmp;
 		if (pixmap_name.startsWith("ERROR")) {
-			pixmap = SmallIcon("laptoppower", width(), TDEIcon::DisabledState);
+			pixmap = SmallIcon("laptoppower", isShown() ? width() : 22, TDEIcon::DisabledState);
 		}
-		else
-			pixmap = SmallIcon(pixmap_name, width());
+		else {
+			pixmap = SmallIcon(pixmap_name, isShown() ? width() : 22);
+		}
 	}
 
 	kdDebugFuncOut(trace);
@@ -443,7 +444,9 @@
 		}
 	}
 quit:
-	image = image.smoothScale(width(), height());
+	if (isShown()) {
+		image = image.smoothScale(width(), height());
+	}
 	fullIcon.convertFromImage(image);
 	setPixmap(fullIcon);