Use scoped window timeout

This commit is contained in:
Andrzej Rybczak
2017-02-13 10:55:46 +01:00
parent 05bf53d0ab
commit 0ab5fbb809
2 changed files with 20 additions and 4 deletions

View File

@@ -2895,8 +2895,7 @@ void seek(SearchDirection sd)
unsigned songpos = Status::State::elapsedTime();
auto t = Timer;
int old_timeout = wFooter->getTimeout();
wFooter->setTimeout(BaseScreen::defaultWindowTimeout);
NC::Window::ScopedTimeout stimeout{*wFooter, BaseScreen::defaultWindowTimeout};
// Accept single action of a given type or action chain for which all actions
// can be run and one of them is of the given type. This will still not work
@@ -3007,8 +3006,6 @@ void seek(SearchDirection sd)
}
SeekingInProgress = false;
Mpd.Seek(Status::State::currentSongPosition(), songpos);
wFooter->setTimeout(old_timeout);
}
void findItem(const SearchDirection direction)

View File

@@ -254,6 +254,25 @@ struct Window
PromptHook m_hook;
};
struct ScopedTimeout
{
ScopedTimeout(Window &w, int new_timeout)
: m_w(w)
{
m_timeout = w.getTimeout();
w.setTimeout(new_timeout);
}
~ScopedTimeout()
{
m_w.setTimeout(m_timeout);
}
private:
Window &m_w;
int m_timeout;
};
Window() : m_window(nullptr) { }
/// Constructs an empty window with given parameters