keditbookmarks crash, KParts related

Daniel Teske teske at squorn.de
Sat Jun 11 15:26:25 BST 2005


Hi,

I'm sorry if my last mail wasn't as clear as I would have liked, let's 
try again.

keditbookmarks has the following code (and that is all the code using 
s_part):

void ActionsImpl::slotPrint() {
    s_part = KParts::ComponentFactory
                        ::createPartInstanceFromQuery<KParts::ReadOnlyPart>(
                                "text/html", QString::null);
    s_part->setProperty("pluginsEnabled", QVariant(false, 1));
    s_part->setProperty("javaScriptEnabled", QVariant(false, 1));
    s_part->setProperty("javaEnabled", QVariant(false, 1));

    // [..] Creating a temporary file "tmpf"

    s_appId = kapp->dcopClient()->appId();
    s_objId = s_part->property("dcopObjectId").toString().latin1();
    connect(s_part, SIGNAL(completed()), this,
                              SLOT(slotDelayedPrint()));

    s_part->openURL(KURL( tmpf.name() ));
}

void ActionsImpl::slotDelayedPrint() {
    Q_ASSERT(s_part);
    DCOPRef(s_appId, s_objId).send("print", false);
    // delete s_part;  -- dies horribly atm
    // TODO - is this a leak?
    s_part = 0;
}

And currently it is crashing on exit if the users has openend the print 
dialog. If I uncomment the "delete s_part" it stops crashing.

> A KParts is a qobject and a qwidget. Both are automatically deleted
> when either one gets deleted, 
Okay, I get that one.

> so if you close the window, the widget tree gets deleted, 
Except that s_part has no parent Widget.
So I need to delete the part, right?

> About reusing: isn't that just a waste of memory, since it's about a
> rare action?
You are right (as always).

daniel




More information about the kfm-devel mailing list