×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    79

    Memory managment

    hello,

    i have a strange behavior in my app.

    I have several QWidget in my app, for each QWidget I have created all object at run time, I haven't used GUI interface.
    I have added to each object this attribute

    setAttribute(Qt::WA_DeleteOnClose,true);

    and I have declared them into my header files, but I have initialized in cpp files.
    Other object are deleted in ~QWidget method using this statement

    object->deleteLater

    So, I navegate between Qwidgets using this statement

    this->close();
    frmCancella *can = new frmCancella();
    can->showNormal();

    frmCancella is my QWidget.

    Sometimes when i navigate between QWidget, my application lost QWidget background image and later my application crashes.

    I receive a message box that informe me about a stack overflow.

    I don't know which component causes the problem, is there a method to understand where is the problem?

    please help me
    marrak

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Memory managment

    Well, if you say
    this ->setAttribute(Qt::WA_DeleteOnClose,true);

    and then say
    this ->close();

    you've kinda sucked all the oxygen out of the room.

    "this" will become a "dangling pointer" and any further references to members of "this" object will be touching random bytes in storage.

    I've never found it necessary to use DeleteOnClose or deleteLater. Normal use of the parenting mechanism takes care of 98% of storage management in Qt.

  3. #3
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    79

    Re: Memory managment

    maybe i'm not clear in my explanation.

    I had set "setAttribute(Qt::WA_DeleteOnClose,true);"

    for each object into my QWidget, not on "this"

    obj1->setAttribute(Qt::WA_DeleteOnClose,true);
    obj2->setAttribute(Qt::WA_DeleteOnClose,true);
    and so on

    when i call another QWidget I use QWidget->close();

    Initially i haven't used any "setAttribute(Qt::WA_DeleteOnClose,true); " statement, but i retrieve error memory message and the application crashes.

    I'm walking alone in the dark.
    ^__^

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Memory managment

    You said you navigate between widgets using
    Code:
    this->close();
    frmCancella *can = new frmCancella();
    can->showNormal();
    If the widget you're in when you do that has the DeleteOnClose attribute then it's going to go poof and leave you standing in midair.

  5. #5
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    79

    Re: Memory managment

    sorry, but i haven't understood what you mean

  6. #6
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Memory managment

    Then I can't help you.

  7. #7
    Regular Contributor
    Join Date
    Dec 2010
    Posts
    79

    Re: Memory managment

    thanks a lot

Similar Threads

  1. version managment of 2 diff. UID
    By juhauta in forum Symbian Tools & SDKs
    Replies: 4
    Last Post: 2011-01-21, 00:52
  2. 6212 cookies managment
    By tboufflet in forum Near Field Communication
    Replies: 1
    Last Post: 2009-12-03, 16:18
  3. NDEF-Managment for the NXP Mifare 4k
    By Feig in forum Near Field Communication
    Replies: 0
    Last Post: 2008-12-16, 13:46
  4. memory managment
    By PeppeM2 in forum Mobile Java General
    Replies: 0
    Last Post: 2007-05-30, 11:37
  5. Symbian memory managment and disassembler
    By stenlik in forum Symbian
    Replies: 0
    Last Post: 2004-05-07, 15:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×