[Uml-devel] kdesdk/umbrello
Sebastian Stein
seb.kde at hpfsc.de
Fri Jul 23 02:09:06 UTC 2004
CVS commit by sstein:
patch by Achim Spangler:
I found the reason for the high CPU load - and fixed it.
Detect:
Simply check with kdbg where the operation is currently, if the program is
interrupted in invisible-state.
=> always something with Qt update events
As I have this high load only with a lot of diagrams, the QCanvas and
QCanvasView classes were suspectible.
Solution:
Switch the update OFF for the QCanvas of a hidden diagram
( QT-Doc states for QCanvas::setUpdatePeriod()
"If ms is less than 0 automatic updating will be stopped. " ),
and switch it back to ON on show event.
Result:
Now even my large project is at a very low CPU load!
Now the work with my project is again smart and quick.
##
Changes:
UMLView::init() :
---------------------
Switch update OFF, as this is started by show event.
( Change call of "canvas() -> setUpdatePeriod( 20 );"
to "canvas() -> setUpdatePeriod( -1 );" )
UMLView::showEvent(QShowEvent* /*se*/) :
----------------------------------------------------------
Start update again with the well working rate of 20msec.
Call "canvas() -> setUpdatePeriod( 20 );" immediately after
"canvas()->setDoubleBuffering( true );"
UMLView::hideEvent(QHideEvent* /*he*/) :
--------------------------------------------------------
Stop update again with "-1" as update rate.
Call "canvas() -> setUpdatePeriod( -1 );" immediately after
"canvas()->setDoubleBuffering( false );"
M +2 -0 ChangeLog 1.24
M +16 -1 umbrello/umlview.cpp 1.163
--- kdesdk/umbrello/ChangeLog #1.23:1.24
@@ -1,4 +1,6 @@
Version 1.3
+* heavily reduced memory usage and CPU load on large projects
+
* reserved keywords added for supported languages
--- kdesdk/umbrello/umbrello/umlview.cpp #1.162:1.163
@@ -146,5 +146,11 @@ void UMLView::init() {
viewport() -> setBackgroundMode( NoBackground );
setCanvas( new UMLViewCanvas( this ) );
- canvas() -> setUpdatePeriod( 20 );
+ // don't set the quite frequent update rate for each
+ // diagram, as that causes also an update of invisible
+ // diagrams, which can cost high CPU load for many
+ // diagrams.
+ // Instead: set the updatePeriod to 20 on Show event,
+ // and switch update back off on Hide event
+ canvas() -> setUpdatePeriod( -1 );
resizeContents(defaultCanvasSize, defaultCanvasSize);
canvas() -> resize(defaultCanvasSize, defaultCanvasSize);
@@ -393,4 +399,8 @@ void UMLView::showEvent(QShowEvent* /*se
kdWarning() << "Show Event for " << getName() << endl;
canvas()->setDoubleBuffering( true );
+ // as the diagram gets now visible again,
+ // the update of the diagram elements shall be
+ // at the normal value of 20
+ canvas()-> setUpdatePeriod( 20 );
# endif
@@ -415,4 +425,9 @@ void UMLView::hideEvent(QHideEvent* /*he
kdWarning() << "Hide Event for " << getName() << endl;
canvas()->setDoubleBuffering( false );
+ // a periodic update of all - also invisible - diagrams
+ // can cause a very high CPU load if more than 100diagrams
+ // are inside a project - and this without any need
+ // => switch the update of for hidden diagrams
+ canvas()-> setUpdatePeriod( -1 );
# endif
}
More information about the umbrello-devel
mailing list