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

List:       kde-panel-devel
Subject:    [PATCH] Suppress errors in Python AppletScripts
From:       Luca Beltrame <einar () heavensinferno ! net>
Date:       2010-07-27 22:03:19
Message-ID: 201007280003.26056.einar () heavensinferno ! net
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


(CCing Simon Edwards as well to get his input)

Hello,

while making a Python
plasmoid today, I noticed that the logs spammed Python exceptions to the
console once the plasmoid got deleted:

AttributeError: 'PythonAppletScript'
object has no attribute 'pluginName'

and also other errors when hovering
over the plasmoid when using plasmoidviewer:

TypeError: invalid result type
from PythonAppletScript.shape()

The attached patch fixes this in
pyappletscript.py, by making shape() return an empty QPainterPath if the
applet is not initialized (removes second error) and by putting a check in
__dtor__ for the applet initialization (fixes first error).

As they're
mostly cosmetic things I'd like to commit them to trunk and 4.5. I haven't
noticed any weird behavior when using them.=20

 Let me know if it's OK.

["plasma_no_python_exceptions.patch" (text/x-patch)]

--- pyappletscript.py.orig	2010-07-27 23:53:21.000000000 +0200
+++ pyappletscript.py	2010-07-27 23:58:09.000000000 +0200
@@ -76,8 +76,11 @@
     def __dtor__(self):
         #print("~PythonAppletScript()")
 
-	PythonAppletScript.importer.unregister_top_level(self.pluginName)
-	self.pyapplet = None
+        if not self.initialized:
+            return
+
+	    PythonAppletScript.importer.unregister_top_level(self.pluginName)
+    	self.pyapplet = None
 
     @pyqtSignature("initExtenderItem(Plasma::ExtenderItem*)")
     def initExtenderItem(self, item):
@@ -121,7 +124,7 @@
 
     def shape(self):
         if not self.initialized:
-            return
+            return QPainterPath()
         return self.pyapplet.shape()
 
     def eventFilter(self, obj, event):

["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