Solved MainWindow deleteLater() segmentation fault
-
If this is RTFM, point me )
Create simple GUI App in Creator, append button and write in slot: deleteLater()
Run it, press this button - segmentation fault take place
In application output "double free or curruption" error shown
Ubuntu 16.04 64Bit, Qt 5.12.0 from offline installer -
Please show use you code.
-
This post is deleted! -
void MainWindow::on_pushButton_clicked() { deleteLater(); }
-
@abarmotov Why do you do this?
-
@jsulm Why i cant ?
Is it unsafe to call QObject::deleteLater() here ? -
@abarmotov It is unusual that an object destroys itself. Can you explain why you're doing this?
The problem is (I guess your code looks like this):void main() { ... MainWindow window; ... app.exec(); // Here window will be destroyed, but you call deleteLater() in in the slot -> double delete }
-
@jsulm yes, forgot about main.cpp )
-
So how does your main.cpp looks like? The same as jsulm posted? Then you must not call deleteLater() since you created MainWindow on the stack.
-
Yes, this is default project main.cpp, i failed to saw where double free occured. But now ok.