Commit 23ccfc4b authored by hjk's avatar hjk

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's avatarEike Ziller <eike.ziller@qt.io>
parent dfcd5734
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment