Page 3 of 3 FirstFirst 123
Results 41 to 46 of 46

Thread: What happens after closing and before destruction?

  1. #41
    Join Date
    Sep 2007
    Location
    Szczecin, Poland
    Posts
    153
    Thanks
    7
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: What happens after closing and before destruction?

    try

    connect(ui.tlbclose,SIGNAL(clicked(bool)),mdi,SLOT (close(void)));

    connect returns bool that is true if connection was successfull.

    And improper connects generates also messages (output window of visual studio)
    See GrEEn (Graphics Effects Environment)
    http://sourceforge.net/project/platf...roup_id=232746
    a qt-based plugins oriented MDI image processing application(contains also qt plugins like styles & imageformats).

  2. The following user says thank you to mchara for this useful post:

    Raccoon29 (19th May 2008)

  3. #42
    Join Date
    Sep 2007
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Post Re: What happens after closing and before destruction?

    We're just guessing here. If we can't reproduce a bug, how can we solve it? You are the one having access to the buggy code [...]
    wysota, you are right.

    Ok, guessing is over.
    Today I "lost" my morning, but now I have the essential code to reproduce the bug, I attach it here.

    Environment
    Qt: v 4.3.4
    OS: Windows Xp Professional
    Compiler: MinGW make 3.80 (mingw32-make)
    Qmake: v 2.01a

    How to reproduce the bug
    From the program start:
    1) Menu: Anagraph->Article managing
    2) Click on "New" button
    3) Position the cursor on a short field below and press F4
    4) Close the appeared window by "Close" button (not the X)
    5) Close the "Article data" window by "Close" button (not the X)
    now the program should exit unexpectedly.

    If between points 4 and 5 you give focus to an underneat window (or to another program), the program will not exit and will close the "Article data" window normally (the infamous focus trick).

    So, what to say... have a nice debugging

    I want to thank you all very much for being still giving help to me, even in a so desperate situation... I'm touched , no other forum gives so much!
    Attached Files Attached Files
    --
    raccoon29

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

  4. #43
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What happens after closing and before destruction?

    Hmm... It seems I am unable to reproduce the bug with Qt 4.4. Which version of Qt are you using? Qt 4.3.4 indeed segfaults. The reason is probably that you destroy a window that contains a button that is currently the source of an emitted signal. Calling deleteLater() instead of deleting the object immediately might be enough to overcome the problem. I'm not sure what your "viewport" does, though, so the problem might be completely elsewhere. Based on what the debugger says, the crash happens while the click on the button is being handled. Taking a look at QMdiSubWindow::closeEvent() and QMdiArea::viewportEvent() might reveal the exact cause.

  5. The following user says thank you to wysota for this useful post:

    Raccoon29 (19th May 2008)

  6. #44
    Join Date
    Sep 2007
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: What happens after closing and before destruction?

    It seems I am unable to reproduce the bug with Qt 4.4. Which version of Qt are you using? Qt 4.3.4 indeed segfaults.
    Uhm, I see.
    So, does it mean that upgrading to Qt4.4 fixes the problem? (As I wrote, mine is Qt 4.3.4)

    Calling deleteLater() instead of deleting the object immediately might be enough to overcome the problem.
    But I don't delete it, I leave this task to the WA_DeleteOnClose...

    I'm not sure what your "viewport" does, though, so the problem might be completely elsewhere.
    "viewport" is nothing special, it just wraps the opening/closing of the mdisubwindows, and several other not dangerous functions (hidden in the debug version I sent you).
    Last edited by Raccoon29; 19th May 2008 at 15:04. Reason: updated contents
    --
    raccoon29

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

  7. #45
    Join Date
    Sep 2007
    Location
    Sant'Elpidio a Mare, Italy
    Posts
    194
    Thanks
    54
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Thumbs up Re: What happens after closing and before destruction?

    I can't believe it! Finally we solved it!
    touched...

    What I did to solve it:

    1_ I forced off the automated desctruction disabling WA_DeleteOnClose
    Qt Code:
    1. void CViewports::open(EViewport win, QWidget* parent)
    2. {
    3. [...]
    4. wArticle->setAttribute(Qt::WA_DeleteOnClose,false); //forced off for every widget
    5. [...]
    6. }
    To copy to clipboard, switch view to plain text mode 

    2_ CViewports desctructor uses deleteLater() instead of delete for every widget,ensures that every widget is destroyed in the right way:
    Qt Code:
    1. if(pArticle)
    2. {
    3. //delete pArticle;
    4. pArticle->deleteLater();
    5. pArticle=NULL;
    6. wArticle=NULL;
    7. }
    To copy to clipboard, switch view to plain text mode 

    3_ Every closeEvent (of every widget) calls its destruction with deleteLater(), instead to delegate it to WA_DeleteOnClose:
    Qt Code:
    1. void frmcustomerorder::closeEvent(QCloseEvent *event)
    2. {
    3. if(!maybeSave())
    4. {
    5. event->ignore();
    6. return;
    7. }
    8.  
    9. viewport->close(CustomerOrder);
    10. //event->accept(); -> no more relies on WA_DeleteOnClose
    11. deleteLater(); // calls its destruction
    12. }
    To copy to clipboard, switch view to plain text mode 

    And in this way it is working (at least until now).

    After N posts we finally found the solution, this forum is simply great.
    Thank you from deep my heart to everyone!

    By the way: wysota, you gave me the main tip to solve it (with deleteLater), and since you answered kindly to my (I admit) boring request, from now on, I'll call you SaintWysota (or shorted S.wysota)
    --
    raccoon29

    "La mia vita finirà quando non vedrò più la gente ridere...non necessariamente alle mie battute "

  8. #46
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What happens after closing and before destruction?

    Oh, I am not saint

    As for your problem - it must have been related to the signal emission I mentioned.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.