Browse Source

Avoid Resource unnecessarily asking for new data when nothing changed.

This wasn't as simple, turns out I had to fix setFallback() to keep
doing the right thing.
dpi-change-events
Vladimír Vondruš 6 years ago
parent
commit
47e1106633
  1. 3
      doc/changelog.dox
  2. 2
      src/Magnum/Resource.h
  3. 3
      src/Magnum/ResourceManager.h

3
doc/changelog.dox

@ -280,6 +280,9 @@ See also:
- Dynamic plugins on static Magnum builds on Windows were accidentally
searched for in the `lib/` directory instead of `bin/`, and in some cases
in `bin/` instead of `lib/` on Unix platforms.
- @ref Resource was unnecessarily querying the @ref ResourceManager for
updated data even in cases where no resource update was done since last
check
@subsection changelog-latest-deprecated Deprecated APIs

2
src/Magnum/Resource.h

@ -285,7 +285,7 @@ template<class T, class U> void Resource<T, U>::acquire() {
if(_state == ResourceState::Final) return;
/* Nothing changed since last check */
if(_manager->lastChange() < _lastCheck) return;
if(_manager->lastChange() <= _lastCheck) return;
/* Acquire new data and save last check time */
const typename Implementation::ResourceManagerData<T>::Data& d = _manager->data(_key);

3
src/Magnum/ResourceManager.h

@ -527,6 +527,9 @@ template<class T> void ResourceManagerData<T>::set(const ResourceKey key, T* con
template<class T> void ResourceManagerData<T>::setFallback(T* const data) {
safeDelete(_fallback);
_fallback = data;
/* Notify resources also in this case, as some of them could go from empty
to a fallback (or from a fallback to empty) */
++_lastChange;
}
template<class T> void ResourceManagerData<T>::free() {

Loading…
Cancel
Save