Why not make KHTMLView::paintBuffer static?
Koos Vriezen
koos.vriezen at xs4all.nl
Sun Aug 11 14:37:02 BST 2002
Hi,
I was wondering if KHTMLView::updateContents could ever be reentranced. If
not, why not .. (see title).
Saves about 256 kb per page with multible tabs/windows, when konqueror
size is 1024x768 in 16 bits color depth.
Attached a patch which makes it so.
Regards,
Koos Vriezen
-------------- next part --------------
Index: khtmlview.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlview.cpp,v
retrieving revision 1.481
diff -u -3 -p -r1.481 khtmlview.cpp
--- khtmlview.cpp 2002/08/01 15:08:21 1.481
+++ khtmlview.cpp 2002/08/11 13:35:56
@@ -46,6 +46,7 @@
#include <kstandarddirs.h>
#include <kprinter.h>
#include <klocale.h>
+#include <kstaticdeleter.h>
#include <qtooltip.h>
#include <qpainter.h>
@@ -94,8 +95,6 @@ public:
underMouse = 0;
reset();
tp=0;
- paintBuffer=0;
- vertPaintBuffer=0;
formCompletions=0;
prevScrollbarVisible = true;
timerId = 0;
@@ -109,8 +108,6 @@ public:
{
delete formCompletions;
delete tp; tp = 0;
- delete paintBuffer; paintBuffer =0;
- delete vertPaintBuffer;
if (underMouse)
underMouse->deref();
delete tooltip;
@@ -184,8 +181,8 @@ public:
}
QPainter *tp;
- QPixmap *paintBuffer;
- QPixmap *vertPaintBuffer;
+ static QPixmap *paintBuffer;
+ static QPixmap *vertPaintBuffer;
NodeImpl *underMouse;
// the node that was selected when enter was pressed
@@ -225,6 +222,11 @@ public:
KHTMLToolTip *tooltip;
};
+KStaticDeleter<QPixmap> s_paintBufferDeleter;
+QPixmap *KHTMLViewPrivate::paintBuffer = 0L;
+KStaticDeleter<QPixmap> s_vertPaintBufferDeleter;
+QPixmap *KHTMLViewPrivate::vertPaintBuffer = 0L;
+
#ifndef QT_NO_TOOLTIP
void KHTMLToolTip::maybeTip(const QPoint& /*p*/)
@@ -287,10 +289,11 @@ KHTMLView::~KHTMLView()
void KHTMLView::init()
{
- if(!d->paintBuffer) d->paintBuffer = new QPixmap(PAINT_BUFFER_HEIGHT, PAINT_BUFFER_HEIGHT);
- if(!d->vertPaintBuffer)
- d->vertPaintBuffer = new QPixmap(10, PAINT_BUFFER_HEIGHT);
if(!d->tp) d->tp = new QPainter();
+ if (!d->paintBuffer) {
+ d->paintBuffer = s_paintBufferDeleter.setObject(new QPixmap(PAINT_BUFFER_HEIGHT, PAINT_BUFFER_HEIGHT));
+ d->vertPaintBuffer = s_vertPaintBufferDeleter.setObject(new QPixmap(10, PAINT_BUFFER_HEIGHT));
+ }
setFocusPolicy(QWidget::StrongFocus);
viewport()->setFocusPolicy( QWidget::WheelFocus );
More information about the kfm-devel
mailing list