[Kst] extragear/graphics/kst/src/libkstapp

George Staikos staikos at kde.org
Fri Apr 21 15:28:04 CEST 2006


SVN commit 532180 by staikos:

space it out a bit and add an assert while trying to debug 125817


 M  +11 -8     kstviewobject.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstviewobject.cpp #532179:532180
@@ -710,32 +710,35 @@
   // FIXME: don't allow regrid to a number of columns that will result in
   //        >= height() plots in a column
   if (cols <= 0) {
-    if (ave_w>0) { // guess current column alignment based on the average width of existing plots
-      cols = int(1.0/ave_w+0.5); 
-      if (cols>cnt) {
+    if (ave_w > 0 ) { // guess current column alignment based on the average width of existing plots
+      cols = int(1.0 / ave_w + 0.5); 
+      if (cols > cnt) {
         cols = int(sqrt(cnt));
       }
     } else {
       cols = int(sqrt(cnt));
     }
   }
+
   if (!_onGrid) {
     _onGrid = true;
     _columns = QMAX(1, cols);
   } else {
     if (cols > 0) {
       _columns = cols;
+      assert(_columns > 0);
     } else if (cols <= 0){
       _columns = QMAX(1, int(sqrt(cnt)));
     }
   }
+
   int rows = ( cnt + _columns - 1 ) / _columns;
 
-  QMemArray<int> plotLoc(rows*_columns); // what plot lives at each grid location
+  QMemArray<int> plotLoc(rows * _columns); // what plot lives at each grid location
   QMemArray<int> unAssigned(cnt); // what plots haven't got a home yet?
   int n_unassigned = 0;
   int r, c, CR;
-  for (int i=0; i<rows*_columns; i++) {
+  for (int i = 0; i < rows * _columns; ++i) {
     plotLoc[i] = -1;
   }
 
@@ -748,7 +751,7 @@
   // NOTE: the choice of grid location assumes a regular grid, which is
   // broken when supressed axis/labels are taken into account.  This
   // could have an effect if the plots are grown by >50%.
-  for (int i=0; i<cnt; i++) {
+  for (int i = 0; i < cnt; ++i) {
     //r = int(childrenCopy[i]->aspectRatio().y*rows+0.5); //use top
     r = int((childrenCopy[i]->aspectRatio().y+childrenCopy[i]->aspectRatio().h/2)*rows); // use center
     c = int(childrenCopy[i]->aspectRatio().x*_columns+0.5);
@@ -787,8 +790,8 @@
   // now dump the unassigned plots in random holes.
   // Question: should be dump them in the closest holes?
   CR = 0;
-  for (int i=0; i<n_unassigned; i++) {
-    for (;plotLoc[CR]!=-1; CR++) { }
+  for (int i = 0; i < n_unassigned; ++i) {
+    for (; plotLoc[CR] != -1; ++CR) { }
     plotLoc[CR] = unAssigned[i];
   }
 


More information about the Kst mailing list