I'm porting an application from Qt 4 to Qt 5, and started using QMacToolBar in the process. The application has two different modes, with different sets of available toolbar buttons. This all works beautifully...until it segfaults while quitting the program. The error I get:
I've managed to reproduce this with a minimal test case, which is attached. Looking at the code, the problem seems to be that in qmactoolbar.mm the QMacToolBar destructor contains:
And the QMacToolBarPrivate destructor contains:
This looks like the memory for toolbar (the underlying NSToolbar) is released twice...and sure enough, if I comment out those lines from the QMacToolBar destructor, both the test case and my real application now exit gracefully.
I'm not sure why this segfault isn't encountered consistently; the mactoolbar example usually works fine, although in tracking down the bug I'm pretty sure I got my application to crash a few times even with just one QMacToolBar instantiated. I'm guessing there's some sort of randomness in the application shutdown, where sometimes the second release attempt doesn't do enough damage to trigger a crash.
Anyway, the fix seems pretty trivial if I'm understanding it correctly, so hopefully this can make it into a release soon.