Use invokeMethod instead of single shot timer with 0 timeout

Refactor it in coreplugin.

Change-Id: I6aaad1b9270a8ff8a4a0bea6a1fff806b2fe190b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Jarek Kobus
2021-01-28 11:29:14 +01:00
parent 9c646d55cd
commit be1d33299e
18 changed files with 28 additions and 38 deletions

View File

@@ -27,7 +27,6 @@
#include "cppeditorconstants.h"
#include <QTimer>
#include <QToolButton>
#include <cpptools/cpptoolssettings.h>
@@ -142,10 +141,8 @@ static InfoBarEntry createMinimizableInfo(const Id &id,
// 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.
info.setCustomButtonInfo(MinimizableInfoBars::tr("Minimize"), [=](){
QTimer::singleShot(0, [=] {
minimizer();
});
info.setCustomButtonInfo(MinimizableInfoBars::tr("Minimize"), [minimizer] {
QMetaObject::invokeMethod(settings(), [minimizer] { minimizer(); }, Qt::QueuedConnection);
});
return info;