[Patch] Fix shutdown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Udo Richter wrote:
> Dominique Simon wrote:
>> I noticed that VDR does not warn anymore if you press the power button 
>> (on the remote) and there is a timer within the next X minutes. 
> 
> One way to fix this would be to always ask, and skip the && 
> !ForceShutdown before asking "Recording in %ld minutes, shut down 
> anyway?". This would result in up to three confirms on shutdown: Running 
> recording, plugin activity and soon recording. For better consistency, 
> its probably a good idea to move this question into the kPower handler, 
> where the other two confirms reside.

The attached patch moves the "Recording in %ld minutes, shut down 
anyway?" confirmation into the kPower handler, where all the other 
shutdown confirms reside. I *hope* that this time it doesn't cause yet 
another regression. ;)

Cheers,

Udo
-------------- next part --------------
--- vdr-1.4.0-orig/vdr.c	2006-05-04 00:07:45.000000000 +0200
+++ vdr-1.4.0/vdr.c	2006-05-04 00:22:43.052229240 +0200
@@ -970,7 +970,7 @@
                   }
                break;
           // Power off:
-          case kPower:
+          case kPower: {
                isyslog("Power button pressed");
                DELETE_MENU;
                if (!Shutdown) {
@@ -985,8 +985,21 @@
                   }
                if (cPluginManager::Active(tr("shut down anyway?")))
                   break;
+                  
+               cTimer *timer = Timers.GetNextActiveTimer();
+               time_t Next  = timer ? timer->StartTime() : 0;
+               time_t Delta = timer ? Next - time(NULL) : 0;
+               if (Next && Delta <= Setup.MinEventTimeout * 60) {
+                  char *buf;
+                  asprintf(&buf, tr("Recording in %ld minutes, shut down anyway?"), Delta / 60);
+                  bool confirm=Interface->Confirm(buf);
+                  free(buf);
+                  if (!confirm) break;
+                  }
+               
                ForceShutdown = true;
                break;
+               }
           default: break;
           }
         Interact = Menu ? Menu : cControl::Control(); // might have been closed in the mean time
@@ -1121,15 +1134,6 @@
                     else
                        LastActivity = 1;
                     }
-                 if (UserShutdown && Next && Delta <= Setup.MinEventTimeout * 60 && !ForceShutdown) {
-                    char *buf;
-                    asprintf(&buf, tr("Recording in %ld minutes, shut down anyway?"), Delta / 60);
-                    if (Interface->Confirm(buf))
-                       ForceShutdown = true;
-                    else
-                       UserShutdown = false;
-                    free(buf);
-                    }
                  if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown) {
                     ForceShutdown = false;
                     if (timer)

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux