diff options
author | hjk <hjk@qt.io> | 2017-11-27 09:12:14 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2017-11-27 09:48:09 +0000 |
commit | 23ccfc4b36a6a7c44cf1a4eb8973dfb7946df7f9 (patch) | |
tree | 5a8c90f863001aab097dc6b3dc275aeee9f67355 /src/libs/utils/basetreeview.cpp | |
parent | dfcd5734278e9e9fc48f4784465cfa4b85dcef4b (diff) |
Utils: Delay saving of treeview column sizes while resizing
As discussed in the linked report, QSettings behavior was changed to
aggressively attempt to sync on each ::setValue() call, therefore causing
excessive disk thrashing when used regularly.
This is arguably a regression on the QSettings side, specifically as the
documentation suggests some kind of delay and therefore merging of quick
sequences of setValue calls (as implemented previously), but since this
opinion is not generally shared, Qt applications need to implement that
behavior now by themselves.
This patch here does that for the reported case in Creator (and uses the
opportunity to delay to 2 secs, which should be sufficient for the case)
Change-Id: I04af0cd1a042abcf7113b5dde5c36e0338f7acb3
Task-number: QTCREATORBUG-15594
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/libs/utils/basetreeview.cpp')
-rw-r--r-- | src/libs/utils/basetreeview.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libs/utils/basetreeview.cpp b/src/libs/utils/basetreeview.cpp index 29c531e1cc5..98b997c5c84 100644 --- a/src/libs/utils/basetreeview.cpp +++ b/src/libs/utils/basetreeview.cpp @@ -51,7 +51,11 @@ class BaseTreeViewPrivate : public QObject public: explicit BaseTreeViewPrivate(BaseTreeView *parent) : q(parent), m_settings(0), m_expectUserChanges(false), m_progressIndicator(0) - {} + { + m_settingsTimer.setSingleShot(true); + connect(&m_settingsTimer, &QTimer::timeout, + this, &BaseTreeViewPrivate::doSaveState); + } bool eventFilter(QObject *, QEvent *event) { @@ -102,6 +106,12 @@ public: void saveState() { + m_settingsTimer.start(2000); // Once per 2 secs should be enough. + } + + void doSaveState() + { + m_settingsTimer.stop(); if (m_settings && !m_settingsKey.isEmpty()) { m_settings->beginGroup(m_settingsKey); QVariantList l; @@ -210,6 +220,7 @@ public: BaseTreeView *q; QMap<int, int> m_userHandled; // column -> width, "not present" means "automatic" QSettings *m_settings; + QTimer m_settingsTimer; QString m_settingsKey; bool m_expectUserChanges; ProgressIndicator *m_progressIndicator; |