This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[SOLVED] uninitialised memory?

Tags: None
(comma "," separated)
K4m1K4tz3
Registered Member
Posts
35
Karma
0

[SOLVED] uninitialised memory?

Sun Mar 08, 2009 4:10 pm
I have a problem with the configuration interface of a little plasmoid which I write at the moment. I have a little QTreeView where the user can see some informations.

In my header file I have

Code: Select all
private:
        QStandardItemModel *model;
        QStandardItem *parentItem;


I also have this function:

Code: Select all
void programm::createConfigurationInterface(KConfigDialog *parent)
{
    ...
    model = new QStandardItemModel;
    parentItem = model->invisibleRootItem();
    ui.tree->setModel(model);
    ...
}


and this:

Code: Select all
void programm::addGroup(QString icon, QString text)
{
    ...
    QStandardItem *item = new QStandardItem(KIcon(icon), text);
    parentItem->appendRow(item);
    parentItem = item;
    ....
}


All of this works fine at the first moment. But if I close the settingdialoge and reopen it, it sometimes crash at parentItem->appendRow(item). So I think parentItem points at uninitialised memory but I don't know why. I don't delete it.

I hope you can help me.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

[SOLVED] uninitialised memory?

Mon Mar 09, 2009 4:59 am
This is because everything created in createConfigurationInterface is automatically destroyed because it is a child of the Configuration dialog, which is destroyed when closed. I would recommend creating the model in init();


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
K4m1K4tz3
Registered Member
Posts
35
Karma
0

[SOLVED] uninitialised memory?

Tue Mar 10, 2009 6:30 pm
bcooksley wrote:This is because everything created in createConfigurationInterface is automatically destroyed because it is a child of the Configuration dialog, which is destroyed when closed. I would recommend creating the model in init();


Thanks, I see. I thought if I write it in the header it won't be deletet. Now I know it better ;-)
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS

[SOLVED] uninitialised memory?

Wed Mar 11, 2009 6:23 am
If you have managed to resolve the problem, could you please mark the thread as solved? Thanks in advance.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell