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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/containments/desktop
From:       Ambroz Bizjak <ambrop7 () gmail ! com>
Date:       2009-02-12 19:10:25
Message-ID: 1234465825.909752.18104.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 925216 by abizjak:

Add safeguards to avoid an infinite loop, compiler/Qt bug suspected.


 M  +23 -3     itemspace.cpp  


--- trunk/KDE/kdebase/workspace/plasma/containments/desktop/itemspace.cpp \
#925215:925216 @@ -219,7 +219,7 @@
     // start either on the left or the right, and advance inside
     qreal x = ((align & Qt::AlignLeft) ? 0 : workingGeom.width()-size.width());
     // try different x coordinates
-    for (int i = 0; i < 100; ++i) {
+    while (1) {
         // stop testing if we're limited by the working area and positions at the \
                next x would reach outside
         bool outOfX = ((align & Qt::AlignLeft) ? (x + size.width() > \
workingGeom.width()) : (x < 0));  if (outOfX && limitedSpace) {
@@ -264,7 +264,18 @@
                 break;
             }
 
-            y = ((align & Qt::AlignTop) ? a.bottom() : a.y() - size.height());
+            // The new coordinate should theoretically always be greater (or lesser \
with right +            // alignment) for the algorithm to terminate. Unfortunatly, \
probably due to some +            // compiler/Qt but, this is not always the case. \
Therefore we have safeguards here. +            qreal newY;
+            if ((align & Qt::AlignTop)) {
+                newY = a.bottom();
+                if (!(newY > y)) return possiblePositions;
+            } else {
+                newY = a.y() - size.height();
+                if (!(newY < y)) return possiblePositions;
+            }
+            y = newY;
         }
 
         // Find next possible x coordinate
@@ -288,7 +299,16 @@
             break;
         }
 
-        x = ((align & Qt::AlignLeft) ? a.right() : a.x() - size.width());
+        // Safeguards to assure termination, see above.
+        qreal newX;
+        if ((align & Qt::AlignLeft)) {
+            newX = a.right();
+            if (!(newX > x)) return possiblePositions;
+        } else {
+            newX = a.x() - size.width();
+            if (!(newX < x)) return possiblePositions;
+        }
+        x = newX;
     }
 
     return possiblePositions;


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

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