commit c863e6e1755c017c84f114a590391fcbaf39210e
parent bb563b4764d75f4a33de4416411f9b87bdfd1a0c
Author: cfillion <cfillion@users.noreply.github.com>
Date: Wed, 21 Sep 2016 22:20:09 -0400
browser: wait before updating the contents of the about window
To avoid huge slowdowns when onSelect() is fired many times per second
(eg. onSelect() is called once for every item when selecting all pkgs)
Diffstat:
2 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -52,7 +52,7 @@ enum Action {
ACTION_MANAGE,
};
-enum Timers { TIMER_FILTER = 100 };
+enum Timers { TIMER_FILTER = 1, TIMER_ABOUT };
Browser::Browser(ReaPack *reapack)
: Dialog(IDD_BROWSER_DIALOG), m_reapack(reapack),
@@ -288,23 +288,16 @@ void Browser::onTimer(const int id)
case TIMER_FILTER:
updateFilter();
break;
+ case TIMER_ABOUT:
+ updateAbout();
+ break;
}
}
void Browser::onSelection()
{
setEnabled(m_list->hasSelection(), m_actionsBtn);
-
- About *about = m_reapack->about(false);
- const Entry *entry = getEntry(m_list->currentIndex());
-
- if(!about || !entry)
- return;
-
- if(about->testDelegate<AboutIndexDelegate>())
- about->setDelegate(make_shared<AboutIndexDelegate>(entry->index, m_reapack));
- else if(about->testDelegate<AboutPackageDelegate>() && entry->package)
- about->setDelegate(make_shared<AboutPackageDelegate>(entry->package, m_reapack));
+ startTimer(100, TIMER_ABOUT);
}
bool Browser::fillContextMenu(Menu &menu, const int index)
@@ -513,6 +506,22 @@ void Browser::updateFilter()
}
}
+void Browser::updateAbout()
+{
+ stopTimer(TIMER_ABOUT);
+
+ About *about = m_reapack->about(false);
+ const Entry *entry = getEntry(m_list->currentIndex());
+
+ if(!about || !entry)
+ return;
+
+ if(about->testDelegate<AboutIndexDelegate>())
+ about->setDelegate(make_shared<AboutIndexDelegate>(entry->index, m_reapack));
+ else if(about->testDelegate<AboutPackageDelegate>() && entry->package)
+ about->setDelegate(make_shared<AboutPackageDelegate>(entry->package, m_reapack));
+}
+
void Browser::refresh(const bool stale)
{
if(m_loading)
diff --git a/src/browser.hpp b/src/browser.hpp
@@ -109,6 +109,7 @@ private:
void transferActions();
bool match(const Entry &) const;
void updateFilter();
+ void updateAbout();
void fillList();
std::string getValue(Column, const Entry &entry) const;
ListView::Row makeRow(const Entry &) const;