Patch: fix for not accounting applets with onLoad events
Koos Vriezen
koos.vriezen at xs4all.nl
Thu Nov 7 21:13:29 GMT 2002
Hi,
Pages with applets fires onLoad events before applets are loaded. The
attached patch fixes that. This also keeps the wheel spinning until they
are loaded.
It also adds some 'const' modifiers on a few KJavaApplet member functions.
Btw. I noticed that applets declared as <APPLET NAME="myapplet" ..> can't
be accessed by using 'document.myapplet' anymore. I thought that that used
to be possible before, no?
Regards,
Koos Vriezen
-------------- next part --------------
Index: khtml_part.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/khtml_part.cpp,v
retrieving revision 1.763
diff -u -3 -p -r1.763 khtml_part.cpp
--- khtml_part.cpp 2002/11/06 22:21:18 1.763
+++ khtml_part.cpp 2002/11/07 20:57:06
@@ -731,6 +731,8 @@ KJavaAppletContext *KHTMLPart::createJav
this, SIGNAL(setStatusBarText(const QString&)) );
connect( d->m_javaContext, SIGNAL(showDocument(const QString&, const QString&)),
this, SLOT(slotShowDocument(const QString&, const QString&)) );
+ connect( d->m_javaContext, SIGNAL(appletLoaded()),
+ this, SLOT(checkCompleted()) );
}
return d->m_javaContext;
@@ -1579,6 +1581,11 @@ void KHTMLPart::checkCompleted()
if ( requests > 0 )
return;
+
+#ifndef Q_WS_QWS
+ if (d->m_javaContext && !d->m_javaContext->appletsLoaded())
+ return;
+#endif
// OK, completed.
// Now do what should be done when we are really completed.
Index: java/kjavaapplet.h
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaapplet.h,v
retrieving revision 1.21
diff -u -3 -p -r1.21 kjavaapplet.h
--- java/kjavaapplet.h 2002/10/17 19:59:26 1.21
+++ java/kjavaapplet.h 2002/11/07 20:57:06
@@ -237,9 +237,9 @@ public:
*/
void stateChange ( const int newState );
void setFailed ();
- AppletState state();
- bool failed();
- bool isAlive();
+ AppletState state() const;
+ bool failed() const;
+ bool isAlive() const;
private:
void showStatus( const QString &msg);
Index: java/kjavaapplet.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaapplet.cpp,v
retrieving revision 1.23
diff -u -3 -p -r1.23 kjavaapplet.cpp
--- java/kjavaapplet.cpp 2002/10/17 19:59:26 1.23
+++ java/kjavaapplet.cpp 2002/11/07 20:57:07
@@ -302,7 +302,7 @@ void KJavaApplet::setFailed() {
d->failed = true;
}
-bool KJavaApplet::isAlive() {
+bool KJavaApplet::isAlive() const {
return (
!d->failed
&& d->state >= INSTANCIATED
@@ -310,11 +310,11 @@ bool KJavaApplet::isAlive() {
);
}
-KJavaApplet::AppletState KJavaApplet::state() {
+KJavaApplet::AppletState KJavaApplet::state() const {
return d->state;
}
-bool KJavaApplet::failed() {
+bool KJavaApplet::failed() const {
return d->failed;
}
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/11/07 20:57:07
@@ -93,6 +93,10 @@ public:
void processCmd( QString cmd, QStringList args );
/**
+ * Check if the applets are loaded by the Java Virtual Machine
+ **/
+ bool appletsLoaded() const;
+ /**
* LiveConnect functions
*/
bool getMember(KJavaApplet *, const unsigned long, const QString &, int &, unsigned long &, QString &);
@@ -110,6 +114,11 @@ signals:
* Signals the KHTML Part to show a url in a given target
*/
void showDocument( const QString& url, const QString& target );
+
+ /**
+ * Signals the KHTML Part an applet is loaded
+ **/
+ void appletLoaded();
protected:
//The counter to generate ID's for the contexts
Index: java/kjavaappletcontext.cpp
===================================================================
RCS file: /home/kde/kdelibs/khtml/java/kjavaappletcontext.cpp,v
retrieving revision 1.32
diff -u -3 -p -r1.32 kjavaappletcontext.cpp
--- java/kjavaappletcontext.cpp 2002/10/24 23:49:05 1.32
+++ java/kjavaappletcontext.cpp 2002/11/07 20:57:07
@@ -30,15 +30,16 @@
#include <qstringlist.h>
#include <qregexp.h>
+typedef QMap< int, QGuardedPtr<KJavaApplet> > AppletMap;
+
// For future expansion
class KJavaAppletContextPrivate
{
friend class KJavaAppletContext;
private:
- QMap< int, QGuardedPtr<KJavaApplet> > applets;
+ AppletMap applets;
};
-
// Static Factory Functions
int KJavaAppletContext::contextCount = 0;
@@ -205,6 +206,8 @@ void KJavaAppletContext::received( const
if (ok)
{
applet->stateChange(newState);
+ if (newState == KJavaApplet::INSTANCIATED)
+ emit appletLoaded();
} else
kdError(6002) << "AppletStateNotification: status is not numerical" << endl;
} else
@@ -226,6 +229,16 @@ void KJavaAppletContext::received( const
applet->setFailed();
}
}
+}
+
+bool KJavaAppletContext::appletsLoaded() const {
+ AppletMap::const_iterator it = d->applets.begin();
+ for (; it != d->applets.end(); it++) {
+ if (!(*it).isNull())
+ if (!(*it)->isAlive())
+ return false;
+ }
+ return true;
}
bool KJavaAppletContext::getMember(KJavaApplet * applet, const unsigned long objid, const QString & name, int & type, unsigned long & rid, QString & value) {
More information about the kfm-devel
mailing list