[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdegames/ktuberling
From:       Albert Astals Cid <tsdgeos () terra ! es>
Date:       2003-12-26 20:21:25
[Download RAW message or body]

CVS commit by aacid: 

'new never returns NULL' --> http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.5
So all those 'if' will never be true and can safely be removed


  M +12 -19    playground.cpp   1.23


--- kdegames/ktuberling/playground.cpp  #1.22:1.23
@@ -120,6 +120,5 @@ bool PlayGround::undo()
   {
     // Undo a "delete" or a "move" action
-    if (!(newObject = new ToDraw(undone->DrawnBefore())))
-      return false;
+    newObject = new ToDraw(undone->DrawnBefore());
     if (!toDraw.insert(zOrder, newObject))
       return false;
@@ -151,6 +150,5 @@ bool PlayGround::redo()
   {
     // Redo an "add" or a "move" action
-    if (!(newObject = new ToDraw(undone->DrawnAfter())))
-      return false;
+    newObject = new ToDraw(undone->DrawnAfter());
     if (!toDraw.insert(zOrder, newObject))
       return false;
@@ -263,6 +261,5 @@ void PlayGround::mousePressEvent( QMouse
   object.setMask(shape);
 
-  if (!(draggedCursor = new QCursor
-       (object, position.x(), position.y()))) return;
+  draggedCursor = new QCursor(object, position.x(), position.y());
   setCursor(*draggedCursor);
 
@@ -303,5 +300,5 @@ void PlayGround::mouseReleaseEvent( QMou
 
     while (history.count() > currentAction) history.removeLast();
-    if (!(newAction = new Action(&draggedObject, draggedZOrder, 0, -1))) return;
+    newAction = new Action(&draggedObject, draggedZOrder, 0, -1);
     history.append(newAction);
     currentAction++;
@@ -312,10 +309,10 @@ void PlayGround::mouseReleaseEvent( QMou
 
   // Register that we have one more object to draw
-  if (!(newObject = new ToDraw(draggedNumber, position))) return;
+  newObject = new ToDraw(draggedNumber, position);
   toDraw.append(newObject);
 
   // Forget all subsequent actions in the undo buffer, and register object's addition (or its move)
   while (history.count() > currentAction) history.removeLast();
-  if (!(newAction = new Action(&draggedObject, draggedZOrder, newObject, toDraw.count()-1))) return;
+  newAction = new Action(&draggedObject, draggedZOrder, newObject, toDraw.count()-1);
   history.append(newAction);
   currentAction++;
@@ -425,9 +422,7 @@ bool PlayGround::loadPlayGround(QDomDocu
 
   delete[] textsLayout;
-  if (!(textsLayout = new QRect[texts]))
-    return false;
+  textsLayout = new QRect[texts];
   delete[] textsList;
-  if (!(textsList = new QString[texts]))
-    return false;
+  textsList = new QString[texts];
 
   for (int text = 0; text < texts; text++)
@@ -466,9 +461,7 @@ bool PlayGround::loadPlayGround(QDomDocu
 
   delete[] objectsLayout;
-  if (!(objectsLayout = new QRect[decorations]))
-    return false;
+  objectsLayout = new QRect[decorations];
   delete[] soundsList;
-  if (!(soundsList = new QString[decorations]))
-    return false;
+  soundsList = new QString[decorations];
 
   for (int decoration = 0; decoration < decorations; decoration++)
@@ -607,7 +600,7 @@ bool PlayGround::loadFrom(const QString 
       return !fclose(fp);
     }
-    if (!(newObject = new ToDraw(readObject))) return false;
+    newObject = new ToDraw(readObject);
     toDraw.append(newObject);
-    if (!(newAction = new Action(0, -1, newObject, toDraw.count()-1))) return false;
+    newAction = new Action(0, -1, newObject, toDraw.count()-1);
     history.append(newAction);
     currentAction++;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic