File amarok-fix-infinite-loop-eating-CPU.diff of Package amarok.openSUSE_12.1_Update
commit 79bd9a7c6777e3f5d4e723bc5d3b00e5d6fe532b
Author: Matěj Laitl <matej@laitl.cz>
Date: Sun Nov 27 15:24:55 2011 +0100
Fix infinite loop in context view eating CPU until main window is shown
We used to use _scene_ sceneRect in
VerticalToolbarContainment::updateGeometry() to update applets and
geometry, but that leaded to infinite loop (across mainloop) -
m_applets->setGeometry(), refresh() would enlarge _scene_ sceneRect by
a few pixels which would trigger updateGeometry() and so on...
We now use _view_ sceneRect to update geometry. Rick W. Chen discovered
some glitches in applet collapsing when this patch is applied, but he
has a patch for that in the works and this is more serious problem, so
pushing this.
REVIEW: 103271
BUG: 278897
FIXED-IN: 2.5
Index: amarok-2.4.3/src/context/containments/verticallayout/VerticalToolbarContainment.cpp
===================================================================
--- amarok-2.4.3.orig/src/context/containments/verticallayout/VerticalToolbarContainment.cpp
+++ amarok-2.4.3/src/context/containments/verticallayout/VerticalToolbarContainment.cpp
@@ -118,7 +118,18 @@ void
Context::VerticalToolbarContainment::updateGeometry()
{
Context::Containment::updateGeometry();
- QRectF rect = scene()->sceneRect();
+
+ /* We used to use _scene_ sceneRect here to update applets and geomtery, but that
+ * leaded to infinite loop (across mainloop) - see bug 278897.
+ * (m_applets->setGeometry(), refresh() would enlarge _scene_ sceneRect by a few
+ * pixels which would trigger updateGeometry() and so on...)
+ *
+ * We now use _view_ sceneRect to update geometry and do nothing without a view
+ */
+ if(!view())
+ return;
+
+ QRectF rect = view()->sceneRect();
setGeometry( rect );
m_applets->setGeometry( rect );
m_applets->refresh();