PauseButton: eliminate potential race condition
authorMichael Moon <triffid.hunter@gmail.com>
Wed, 6 Mar 2013 03:35:17 +0000 (14:35 +1100)
committerMichael Moon <triffid.hunter@gmail.com>
Wed, 6 Mar 2013 03:35:17 +0000 (14:35 +1100)
src/modules/utils/pausebutton/PauseButton.cpp

index e3e2beb..d8c8529 100644 (file)
@@ -25,8 +25,9 @@ void PauseButton::on_module_loaded(){
 uint32_t PauseButton::button_tick(uint32_t dummy){
     if(!this->enable) return 0;
     // If button changed
-    if(this->button_state != this->button.get()){
-        this->button_state = this->button.get();
+    bool newstate = this->button.get();
+    if(this->button_state != newstate){
+        this->button_state = newstate;
         // If button pressed
         if( this->button_state ){
             if( this->play_state ){