Index: umbrello/codegenerators/cppheadercodedocument.cpp
===================================================================
--- umbrello/codegenerators/cppheadercodedocument.cpp	(revision 704380)
+++ umbrello/codegenerators/cppheadercodedocument.cpp	(working copy)
@@ -281,12 +281,24 @@
         switch (scope) {
         default:
               case Uml::Visibility::Public:
+            if (!pubOperationsBlock) {
+                kDebug() << "pubOperationsBlock is zero"; 
+                return false;
+            }
             return pubOperationsBlock->addTextBlock(op);
             break;
               case Uml::Visibility::Protected:
+            if (!protOperationsBlock) {
+                kDebug() << "protOperationsBlock is zero"; 
+                return false;
+            }
             return protOperationsBlock->addTextBlock(op);
             break;
               case Uml::Visibility::Private:
+            if (!privOperationsBlock) {
+                kDebug() << "privOperationsBlock is zero"; 
+                return false;
+            }
             return privOperationsBlock->addTextBlock(op);
             break;
         }
@@ -294,12 +306,24 @@
         switch (scope) {
         default:
               case Uml::Visibility::Public:
+            if (!pubConstructorBlock) {
+                kDebug() << "pubConstructorBlock is zero"; 
+                return false;
+            }
             return pubConstructorBlock->addTextBlock(op);
             break;
               case Uml::Visibility::Protected:
+            if (!protConstructorBlock) {
+                kDebug() << "protConstructorBlock is zero"; 
+                return false;
+            }
             return protConstructorBlock->addTextBlock(op);
             break;
               case Uml::Visibility::Private:
+            if (!privConstructorBlock) {
+                kDebug() << "privConstructorBlock is zero"; 
+                return false;
+            }
             return privConstructorBlock->addTextBlock(op);
             break;
         }
@@ -364,7 +388,7 @@
     CodeClassFieldList privAggregationClassFields = getSpecificClassFields ( CodeClassField::Aggregation, Uml::Visibility::Private);
     CodeClassFieldList privCompositionClassFields = getSpecificClassFields ( CodeClassField::Composition, Uml::Visibility::Private);
 
-    bool hasOperationMethods = c->getOpList().last() ? true : false;
+    bool hasOperationMethods = !c->getOpList().isEmpty() && c->getOpList().last() ? true : false;
     bool hasNamespace = false;
     bool isEnumeration = false;
     bool isInterface = parentIsInterface();
Index: umbrello/codegenerators/cppsourcecodedocument.cpp
===================================================================
--- umbrello/codegenerators/cppsourcecodedocument.cpp	(revision 704380)
+++ umbrello/codegenerators/cppsourcecodedocument.cpp	(working copy)
@@ -87,8 +87,16 @@
 
     if(!op->getParentOperation()->isLifeOperation())
     {
+        if (!methodsBlock) {
+            kDebug() << "methodsBlock is zero"; 
+            return false;
+        }
         return methodsBlock->addTextBlock(op);
     } else
+        if (!constructorBlock) {
+            kDebug() << "constructorBlock is zero"; 
+            return false;
+        }
         return constructorBlock->addTextBlock(op);
 }
 
Index: umbrello/umlwidgetcontroller.cpp
===================================================================
--- umbrello/umlwidgetcontroller.cpp	(revision 704380)
+++ umbrello/umlwidgetcontroller.cpp	(working copy)
@@ -446,7 +446,7 @@
 
 //TODO refactor with AlignToolbar method.
 int UMLWidgetController::getSmallestX(const UMLWidgetList &widgetList) {
-    int smallestX ;
+    int smallestX = 0;
     int i = 1;
     foreach ( UMLWidget* widget , widgetList ) {
         if ( i == 1 ) {
@@ -466,7 +466,7 @@
 //TODO refactor with AlignToolbar method.
 int UMLWidgetController::getSmallestY(const UMLWidgetList &widgetList) {
 
-    int smallestY ;
+    int smallestY = 0;
     int i = 1;
     foreach ( UMLWidget* widget , widgetList ) {
         if ( i == 1 ) {
@@ -487,7 +487,7 @@
 //TODO refactor with AlignToolbar method.
 int UMLWidgetController::getBiggestX(const UMLWidgetList &widgetList) {
 
-    int biggestX ;
+    int biggestX = 0;
 
     int i = 1;
     foreach ( UMLWidget* widget , widgetList ) {
@@ -509,7 +509,7 @@
 //TODO refactor with AlignToolbar method.
 int UMLWidgetController::getBiggestY(const UMLWidgetList &widgetList) {
 
-    int biggestY ;
+    int biggestY = 0;
     int i = 1;
     foreach ( UMLWidget* widget , widgetList ) {
         if ( i == 1 ) {
