Solved The Qt App breaks down during deconstruction of MainWin
-
qwid1 is deleted two times !
MainWin::MainWin(QWidget* parent) : QMainWindow(parent) { qwid1 = new QWid1(this); -----> deleted by MainWindow qwid1->setGeometry(0, 0, 800, 500); resizeFrame(); } MainWin::~MainWin() { delete qwid1; ----> no need to delete it, already made by MainWindow }
Same error here:
QWid1::~QWid1() { delete button; }
-
adding to @mpergand
please see here
http://doc.qt.io/qt-5/objecttrees.html -
What do you have in
pbExit_Slot
and what's the stack trace from the crash? -
@kshegunov what is a stack trace?
A list of the routines called at the time it freezes??
I have a jpg of a screen shot but how do I put a jpg onto this ??in pbExit_Slot() :
void MainWin::pbExit_Slot() { try { close(); } catch(QException e) { std::cout << "Exception error in MainWin::pbExit_Slot()" << std::endl; } } // void MainWin::pbExit_Slot()
[Added code tags ~kshegunov]
-
@mpergand qwid1 is a QWid1 object, button is a QPushButton object.....two different things
I see delete qwid1 deleted one single time, in the destructor of MainWin
Why would MainWin delete a member without writing "delete qwid1" ?P.S. what are code tags?
-
@Rapidrain
If you assign an owner to a widget, the owner will delete it.
Please read this
http://doc.qt.io/qt-5/objecttrees.html -
@Rapidrain said in The Qt App breaks down during deconstruction of MainWin:
what is a stack trace?
A list of the function calls (since they are put in the stack, hence the name). See here for a general discussion. Are you running your program through the debugger, if not, you should. Whenever the crash occurs the call stack will be visible in the "stack" window of the debugger view.
I have a jpg of a screen shot but how do I put a jpg onto this ??
Upload it somewhere (e.g. postimage.org) and then use
![](http:site.com/image/url)
in your post to show it.P.S. what are code tags?
Before posting any code insert ``` (three back quotes) on their own line, then add your code, and finish with another three backquotes to finish the code block, this will format it in a readable fashion.
-
mrjj had the answer in that link to a qt doc page
Wow.
I've worked and doodled with Qt for almost 10 years and I had never heard of this self-deletion of objects on the heap.
Never had a problem until now.
As with the code tags, learning by making mistakes here, and your odd manner of uploading jpgs, also learning by making mistakes, I had to make the mistake with this app to find out about self-deletion.Thanks to mrjj.
-
@Rapidrain
Np.
The owner system is pretty handy as you do not have to clean up manually and it help reduce
the change of leaks.Regarding the code tags. Its the last button
-
@mrjj
Thanks mrjj. Someone here said I should use three "back quotes".
</> does not look like a back quote to me.
And hovering over the symbol shows no mini-text explanation.
Are explanations expensive? -
@Rapidrain said in The Qt App breaks down during deconstruction of MainWin:
And hovering over the symbol shows no mini-text explanation.
Are explanations expensive?Hi Rapidrain,
That's a known issue that has been reported already. It should be in the next Forum update, which is in testing fase now.
Explanations are not expensive since we are all volunteers here trying to help each other with Qt. ;-)
If you want to dive deeper in the editor here are some links :
wiki page on editor
link to cheatsheetsFeel free to add more information to the wiki page if you think it's not good enough.
Eddy
-
- </> does not look like a back quote to me.
Well its a symbol/icon for tag.
It inserts the back quotes.