[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    webkit scriptengine & multiple plasmoids
From:       Petri =?iso-8859-1?q?Damst=E9n?= <petri.damsten () gmail ! com>
Date:       2009-12-17 18:04:34
Message-ID: 200912172004.35565.petri.damsten () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi,

I'm trying to fix this bug: http://www.kde-
look.org/content/show.php/Scripted+Image?content=91749 (Error having 2 of 
them). Seems that if there is two (or more) same webkit plasmoids on desktop 
only one of them loads properly on plasma start. When same plasmoid B load is 
started before A load is finished javascript functions don't get called. This 
happens only when plasmoids are same e.g. two scripted-image plasmoids. I made 
attached patch to load plasmoids with the same plugin name in queue and it 
seems to solve this but I'm not sure if this right way to do it?

Petri

["webkit.diff" (text/x-patch)]

Index: webapplet.cpp
===================================================================
--- webapplet.cpp	(revision 1063166)
+++ webapplet.cpp	(working copy)
@@ -28,6 +28,7 @@
 #include <QWebFrame>
 #include <QWebPage>
 #include <QFile>
+#include <QTimer>
 
 #include <Plasma/Applet>
 #include <Plasma/Package>
@@ -67,8 +68,13 @@
 
     Plasma::WebView *page;
     bool loaded;
+    KUrl url;
+    QString webpage;
+    static QMap<QString, bool> loading;
 };
 
+QMap<QString, bool> WebApplet::Private::loading;
+
 WebApplet::WebApplet(QObject *parent, const QVariantList &args)
     : AppletScript(parent),
       d(new Private)
@@ -86,20 +92,31 @@
     d->init(this);
 
     QString webpage;
-    webpage = package()->filePath("mainscript");
+    d->webpage = package()->filePath("mainscript");
 
-    if (webpage.isEmpty()) {
+    if (d->webpage.isEmpty()) {
         kDebug() << "fail! no page";
         delete d->page;
         d->page = 0;
         return false;
     }
-    KUrl url(package()->filePath("html"));
-    kDebug() << webpage << package()->path() << url;
-    d->page->mainFrame()->setHtml(dataFor(webpage), url);
+    d->url = KUrl(package()->filePath("html"));
+    kDebug() << d->webpage << package()->path() << d->url;
+    load();
     return true;
 }
 
+void WebApplet::load()
+{
+    if (!d->loading.contains(package()->metadata().pluginName()) ||
+        !d->loading[package()->metadata().pluginName()]) {
+        d->loading[package()->metadata().pluginName()] = true;
+        d->page->mainFrame()->setHtml(dataFor(d->webpage), d->url);
+    } else {
+        QTimer::singleShot(50, this, SLOT(load()));
+    }
+}
+
 void WebApplet::paintInterface(QPainter *painter,
                                const QStyleOptionGraphicsItem *option,
                                const QRect &contentsRect)
@@ -116,6 +133,7 @@
 
 void WebApplet::loadFinished(bool success)
 {
+    d->loading[package()->metadata().pluginName()] = false;
     d->loaded = success;
 }
 
Index: webapplet.h
===================================================================
--- webapplet.h	(revision 1063166)
+++ webapplet.h	(working copy)
@@ -56,6 +56,7 @@
     void connectFrame(QWebFrame *);
     virtual void loadFinished(bool);
     virtual void initJsObjects();
+    void load();
 
 private:
     class Private;

["signature.asc" (application/pgp-signature)]

_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic