Pages with Java don't like being left

Koos Vriezen koos.vriezen at xs4all.nl
Sun Aug 18 14:15:52 BST 2002


On Fri, 16 Aug 2002, Koos Vriezen wrote:

> First, as you may noticed, the fix is in CVS now. Remove it, if another
> solution is found eg. only deleteLater when scripts are running or events
> being dispatched (didn't test these).

Beter use ref/deref in KJavaAppletContext. Attached a patch which does so.
Ok to commit?

Koos
-------------- next part --------------
Index: khtml_part.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
retrieving revision 1.728
diff -u -3 -p -r1.728 khtml_part.cpp
--- khtml_part.cpp	2002/08/18 11:18:12	1.728
+++ khtml_part.cpp	2002/08/18 13:09:19
@@ -706,6 +706,7 @@ KJavaAppletContext *KHTMLPart::createJav
 #ifndef Q_WS_QWS
   if ( !d->m_javaContext ) {
       d->m_javaContext = new KJavaAppletContext();
+      d->m_javaContext->ref();
       connect( d->m_javaContext, SIGNAL(showStatus(const QString&)),
                this, SIGNAL(setStatusBarText(const QString&)) );
       connect( d->m_javaContext, SIGNAL(showDocument(const QString&, const QString&)),
@@ -908,8 +909,10 @@ void KHTMLPart::clear()
   d->m_objects.clear();
 
 #ifndef Q_WS_QWS
-  delete d->m_javaContext;
-  d->m_javaContext = 0;
+  if (d->m_javaContext) {
+    d->m_javaContext->deref();
+    d->m_javaContext = 0;
+  }
 #endif
 
   d->m_delayRedirect = 0;
Index: khtmlpart_p.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtmlpart_p.h,v
retrieving revision 1.20
diff -u -3 -p -r1.20 khtmlpart_p.h
--- khtmlpart_p.h	2002/07/26 17:09:09	1.20
+++ khtmlpart_p.h	2002/08/18 13:09:19
@@ -183,7 +183,8 @@ public:
     if ( m_kjs_lib)
        m_kjs_lib->unload();
 #ifndef Q_WS_QWS
-    delete m_javaContext;
+    if (m_javaContext)
+        m_javaContext->deref();
 #endif
   }
 
Index: java/kjavaapplet.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaapplet.cpp,v
retrieving revision 1.22
diff -u -3 -p -r1.22 kjavaapplet.cpp
--- java/kjavaapplet.cpp	2002/06/30 19:17:16	1.22
+++ java/kjavaapplet.cpp	2002/08/18 13:09:20
@@ -53,6 +53,7 @@ KJavaApplet::KJavaApplet( KJavaAppletWid
         context = _context;
     else
         context = new KJavaAppletContext();
+    context->ref();
 
     d->reallyExists = false;
     id = -1;
@@ -62,6 +63,7 @@ KJavaApplet::~KJavaApplet()
 {
     if ( d->reallyExists )
         context->destroy( this );
+    context->deref();
 
     delete d;
     delete liveconnect;
Index: java/kjavaappletcontext.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaappletcontext.cpp,v
retrieving revision 1.30
diff -u -3 -p -r1.30 kjavaappletcontext.cpp
--- java/kjavaappletcontext.cpp	2002/07/06 02:38:47	1.30
+++ java/kjavaappletcontext.cpp	2002/08/18 13:09:20
@@ -59,6 +59,7 @@ KJavaAppletContext::~KJavaAppletContext(
     server->destroyContext( id );
     KJavaAppletServer::freeJavaServer();
     delete d;
+    kdDebug(6100) << "KJavaAppletContext::~KJavaAppletContext" << endl;
 }
 
 int KJavaAppletContext::contextId()
Index: java/kjavaappletcontext.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaappletcontext.h,v
retrieving revision 1.17
diff -u -3 -p -r1.17 kjavaappletcontext.h
--- java/kjavaappletcontext.h	2002/05/25 11:50:27	1.17
+++ java/kjavaappletcontext.h	2002/08/18 13:09:20
@@ -25,6 +25,7 @@
 #define KJAVAAPPLETCONTEXT_H
 
 #include <qobject.h>
+#include "misc/shared.h"
 
 /**
  * @short Provides a context for KJavaAppletWidgets
@@ -43,7 +44,7 @@ class KJavaAppletServer;
 class KJavaApplet;
 class KJavaAppletContextPrivate;
 
-class KJavaAppletContext : public QObject
+class KJavaAppletContext : public QObject, public khtml::Shared<KJavaAppletContext>
 {
 Q_OBJECT
 
Index: rendering/render_applet.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/rendering/render_applet.cpp,v
retrieving revision 1.37
diff -u -3 -p -r1.37 render_applet.cpp
--- rendering/render_applet.cpp	2002/08/16 18:38:52	1.37
+++ rendering/render_applet.cpp	2002/08/18 13:09:20
@@ -64,8 +64,6 @@ RenderApplet::RenderApplet(HTMLElementIm
 
 RenderApplet::~RenderApplet()
 {
-    delete m_widget;
-    m_widget = 0L;
 }
 
 short RenderApplet::intrinsicWidth() const


More information about the kfm-devel mailing list