diff options
author | jasplin <qt-info@nokia.com> | 2009-05-07 08:09:14 (GMT) |
---|---|---|
committer | jasplin <qt-info@nokia.com> | 2009-05-07 08:11:45 (GMT) |
commit | 515991426832a6333f2fd9e639bd4c83e2b27cef (patch) | |
tree | ce4896d65b77cc355631945e336e71ac8d37db7a /src/gui/graphicsview/qgraphicslayoutitem_p.h | |
parent | 73b519015e16d0cd265a1955419e409ba74ce3e4 (diff) | |
download | Qt-515991426832a6333f2fd9e639bd4c83e2b27cef.zip Qt-515991426832a6333f2fd9e639bd4c83e2b27cef.tar.gz Qt-515991426832a6333f2fd9e639bd4c83e2b27cef.tar.bz2 |
Reduced memory footprint of QGraphicsWidget.
This commit reduces the memory footprint of QGraphicsWidget by
around 40% (from around 663 bytes to around 409 bytes - measured
using /proc/<pid>/statm on Linux - see 'man 5 proc').
The technique used is to lazily allocate (on the heap) certain
data structures (i.e. not allocate them unless they are needed):
- QGraphicsLayoutItemPrivate::userSizeHints
=> used only if the size, width, or height is explicitly set
- QGraphicsWidgetPrivate::margins
=> used only if the contents margins are accessed
- QGraphicsWidgetPrivate::windowFrameMargins
=> used only if the window frame margins are accessed
- QGraphicsWidgetPrivate::windowData
=> used only if the graphics widget is a window
In addition, a few unused data members (and related code) were removed:
- QGraphicsWidgetPrivate::contentsRect
- QGraphicsWidgetPrivate::mouseDelta
- QGraphicsWidgetPrivate::*LayoutItemMargin
Reviewed-by: andreas
Task-number: 251592
Diffstat (limited to 'src/gui/graphicsview/qgraphicslayoutitem_p.h')
-rw-r--r-- | src/gui/graphicsview/qgraphicslayoutitem_p.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicslayoutitem_p.h b/src/gui/graphicsview/qgraphicslayoutitem_p.h index fab0f39..dc044e6 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem_p.h +++ b/src/gui/graphicsview/qgraphicslayoutitem_p.h @@ -63,16 +63,20 @@ class Q_AUTOTEST_EXPORT QGraphicsLayoutItemPrivate { Q_DECLARE_PUBLIC(QGraphicsLayoutItem) public: - virtual ~QGraphicsLayoutItemPrivate() {} + virtual ~QGraphicsLayoutItemPrivate(); QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *parent, bool isLayout); void init(); QSizeF *effectiveSizeHints(const QSizeF &constraint) const; QGraphicsItem *parentItem() const; + void ensureUserSizeHints(); + void setSize(Qt::SizeHint which, const QSizeF &size); + enum SizeComponent { Width, Height }; + void setSizeComponent(Qt::SizeHint which, SizeComponent component, qreal value); QSizePolicy sizePolicy; QGraphicsLayoutItem *parent; - QSizeF userSizeHints[Qt::NSizeHints]; + QSizeF *userSizeHints; mutable QSizeF cachedSizeHints[Qt::NSizeHints]; mutable QSizeF cachedConstraint; |