Core: Fix memory leak in InfoBarEntry

Use like

    InfoBarEntry info(id, text);
    info.setShowDefaultCancelButton(false);

leaked the infoWidgetCloseButton.

Fix the memory leak and improve the API to avoid inconsistent state.

Change-Id: If2e06a8a5239e4f902a883da82122c3a27df48a6
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-01-17 17:43:44 +01:00
parent e2e78c6a5d
commit b250c073b5
3 changed files with 22 additions and 15 deletions

View File

@@ -140,7 +140,7 @@ static InfoBarEntry createMinimizableInfo(const Id &id,
QTC_CHECK(minimizer);
InfoBarEntry info(id, text);
info.setShowDefaultCancelButton(false);
info.removeCancelButton();
// The minimizer() might delete the "Minimize" button immediately and as
// result invalid reads will happen in QToolButton::mouseReleaseEvent().
// Avoid this by running the minimizer in the next event loop iteration.