[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:00:32
[Download RAW message or body]

CVS commit by aacid: 

There is no need to check a object is not null when deleting it. \
http://www.parashift.com/c++-faq-lite/freestore-mgmt.html#faq-16.7 Disable the redo \
and undo buttons when changing playground Delete some objects before allocating new \
ones as this was leaking memory (found thanks to valgrind)


  M +9 -5      playground.cpp   1.22
  M +4 -0      toplevel.cpp   1.61


--- kdegames/ktuberling/playground.cpp  #1.21:1.22
@@ -52,11 +52,11 @@ PlayGround::PlayGround(TopLevel *parent,
 PlayGround::~PlayGround()
 {
-  if (textsLayout) delete [] textsLayout;
-  if (objectsLayout) delete [] objectsLayout;
+  delete [] textsLayout;
+  delete [] objectsLayout;
 
-  if (textsList) delete [] textsList;
-  if (soundsList) delete [] soundsList;
+  delete [] textsList;
+  delete [] soundsList;
 
-  if (draggedCursor) delete draggedCursor;
+  delete draggedCursor;
 }
 
@@ -424,6 +424,8 @@ bool PlayGround::loadPlayGround(QDomDocu
     return false;
 
+  delete[] textsLayout;
   if (!(textsLayout = new QRect[texts]))
     return false;
+  delete[] textsList;
   if (!(textsList = new QString[texts]))
     return false;
@@ -463,6 +465,8 @@ bool PlayGround::loadPlayGround(QDomDocu
     return false;
 
+  delete[] objectsLayout;
   if (!(objectsLayout = new QRect[decorations]))
     return false;
+  delete[] soundsList;
   if (!(soundsList = new QString[decorations]))
     return false;

--- kdegames/ktuberling/toplevel.cpp  #1.60:1.61
@@ -161,4 +161,8 @@ void TopLevel::changeGameboard(uint newG
   // Change gameboard effectively
   playGround->change(newGameboard);
+
+  // Disable undo and redo actions
+  enableUndo(false);
+  enableRedo(false);
 }
 


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

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