Use RAII instead of lock->unlock directly.
This commit is contained in:
parent
d55e884280
commit
aa58d83b45
3 changed files with 17 additions and 5 deletions
|
@ -2720,10 +2720,9 @@ void display::draw(bool update,bool force) {
|
|||
}
|
||||
|
||||
if (dirty_) {
|
||||
flip_locker flip_lock(screen_);
|
||||
dirty_ = false;
|
||||
screen_.lock_flips(true);
|
||||
redraw_everything();
|
||||
screen_.lock_flips(false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -471,7 +471,7 @@ void pump()
|
|||
}
|
||||
case DRAW_ALL_EVENT:
|
||||
{
|
||||
CVideo::get_singleton().lock_flips(true);
|
||||
flip_locker flip_lock(CVideo::get_singleton());
|
||||
/* iterate backwards as the most recent things will be at the top */
|
||||
for( std::deque<context>::iterator i = event_contexts.begin() ; i != event_contexts.end(); ++i) {
|
||||
const std::vector<sdl_handler*>& event_handlers = (*i).handlers;
|
||||
|
@ -479,8 +479,6 @@ void pump()
|
|||
(*i1)->handle_event(event);
|
||||
}
|
||||
}
|
||||
CVideo::get_singleton().lock_flips(false);
|
||||
//CVideo::get_singleton().flip();
|
||||
continue; //do not do further handling here
|
||||
}
|
||||
|
||||
|
|
|
@ -272,6 +272,21 @@ private:
|
|||
bool unlock;
|
||||
};
|
||||
|
||||
class flip_locker
|
||||
{
|
||||
public:
|
||||
flip_locker(CVideo &video) : video_(video) {
|
||||
video_.lock_flips(true);
|
||||
}
|
||||
~flip_locker() {
|
||||
video_.lock_flips(false);
|
||||
}
|
||||
|
||||
private:
|
||||
CVideo& video_;
|
||||
};
|
||||
|
||||
|
||||
namespace video2 {
|
||||
class draw_layering: public events::sdl_handler {
|
||||
protected:
|
||||
|
|
Loading…
Add table
Reference in a new issue