Hello, I just got started with a simple Python-based Plasma widget. Right now I'm getting segfaults I cannot explain; so maybe someone could give me a hint, whether this is really a bug or a my fault.
I roughly followed an howto from techbase and everything works fine until I call "addStretch" on a QGraphicsLinearLayout instance. Then I'm getting a segfault with the following backtrace: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0xb3db9720 (LWP 11622)] 0xb741e737 in QGraphicsLayoutItem::isLayout () from /usr/lib/libQtGui.so.4 (gdb) bt #0 0xb741e737 in QGraphicsLayoutItem::isLayout () from /usr/lib/libQtGui.so.4 #1 0xa85debf1 in ?? () from /usr/lib/pymodules/python2.5/PyQt4/QtGui.so #2 0xa8b60bdd in PyCFunction_Call (func=0xa7078a6c, arg=0xa772a48c, kw=0x0) at ../Objects/methodobject.c:73 #3 0xa8bb2f09 in PyEval_EvalFrameEx (f=0x846620c, throwflag=0) at ../Python/ceval.c:3612 #4 0xa8bb3e3f in PyEval_EvalFrameEx (f=0x84012cc, throwflag=0) at ../Python/ceval.c:3698 #5 0xa8bb488d in PyEval_EvalCodeEx (co=0xa8a8f800, globals=0xa8a9e3e4, locals=0x0, args=0xa772a738, argcount=1, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0) at ../Python/ceval.c:2875 #6 0xa8b4b5fa in function_call (func=0xa7fd5bc4, arg=0xa772a72c, kw=0x0) at ../Objects/funcobject.c:517 #7 0xa8b27a47 in PyObject_Call (func=0x0, arg=0xa772a72c, kw=0x0) at ../Objects/abstract.c:1861 #8 0xa8b2f875 in instancemethod_call (func=0xa7fd5bc4, arg=0xa772a72c, kw=0x0) at ../Objects/classobject.c:2519 #9 0xa8b27a47 in PyObject_Call (func=0x0, arg=0xa8ac502c, kw=0x0) at ../Objects/abstract.c:1861 #10 0xa8bacb8c in PyEval_CallObjectWithKeywords (func=0xa772966c, arg=0xa8ac502c, kw=0x0) at ../Python/ceval.c:3481 #11 0xb3b2e883 in ?? () from /usr/lib/python2.5/site-packages/sip.so #12 0xa772966c in ?? () #13 0xa8ac502c in ?? () #14 0x00000000 in ?? () And here is the actual code. class LosungApplet(plasmascript.Applet): def __init__(self,parent,args=None): plasmascript.Applet.__init__(self,parent) @pyqtSignature("strLinkClicked(const QString &)") def strLinkClicked(self, url): self.linkClicked(QUrl(url)) @pyqtSignature("linkClicked(const QUrl &)") def linkClicked(self, url): #webbrowser.open(url.toString(), new=2) kio.KRun.runUrl(kdecore.KUrl(url), "text/html", None) def _setupWebView(self, losung): webView = Plasma.WebView(self.applet) webView.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks) QObject.connect(webView.page(), SIGNAL("linkClicked( const QUrl & )"), self.linkClicked) r = LosungenRenderer() webView.setHtml(r.renderLosung(losung)) return webView def _setupLabel(self, losung): label = Plasma.Label() nw = label.nativeWidget() nw.setTextInteractionFlags(Qt.TextBrowserInteraction) QObject.connect(label, SIGNAL("linkActivated( const QString & )"), self.strLinkClicked) r = LosungenRenderer() label.setText(r.renderLosung(losung)) return label def init(self): self.setHasConfigurationInterface(True) self.setAspectRatioMode(Plasma.IgnoreAspectRatio) self.losungenDB = LosungenDB("%s%s"%(self.package().path(), LOSUNGEN_CSV)) self.theme = Plasma.Svg(self) self.theme.setImagePath("widgets/background") self.setBackgroundHints(Plasma.Applet.DefaultBackground) arrowLeftIcon = kdeui.KIcon("arrow-left") arrowRightIcon = kdeui.KIcon("arrow-right") goTodayIcon = kdeui.KIcon("go-jump-today") self.arrowLeft = Plasma.ToolButton() self.arrowLeft.nativeWidget().setIcon(arrowLeftIcon) self.arrowLeft.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.arrowRight = Plasma.ToolButton() self.arrowRight.nativeWidget().setIcon(arrowRightIcon) self.goToday = Plasma.ToolButton() self.goToday.nativeWidget().setIcon(goTodayIcon) losung = self.losungenDB.getLosung(datetime.date.today()) self.contentWidget = self._setupLabel(losung) #self.layout = QGraphicsLinearLayout(Qt.Vertical, self.applet) buttons = QGraphicsLinearLayout(Qt.Horizontal, self.applet) buttons.addItem(self.arrowLeft) buttons.addStretch() buttons.addItem(self.goToday) buttons.addStretch() buttons.addItem(self.arrowRight) #self.layout.addItem(self.contentWidget) #self.layout.addItem(buttons) self.setLayout(buttons) self.resize(350,200) def paintInterface(self, painter, option, rect): pass def CreateApplet(parent): return LosungApplet(parent) Thanks a lot for any hints, Johannes Wolter _______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel