Ticket #9102: proper_shutdown_behavior_for_ubuntu.2.patch

File proper_shutdown_behavior_for_ubuntu.2.patch, 1.9 KB (added by superm1@…, 9 years ago)

updated for sphery's comments in #mythtv

  • programs/mythfrontend/exitprompt.cpp

    ## Description: Fixes up the shutdown behavior so users can't break it
    ## Origin/Author: Mario Limonciello
    ## Upstream URL: http://svn.mythtv.org/trac/ticket/9102
    old new  
    1212#include "mythmainwindow.h"
    1313#include "mythscreenstack.h"
    1414#include "mythsystem.h"
     15#include "mythverbose.h"
    1516
    1617void ExitPrompter::quit()
    1718{
     
    6465{
    6566
    6667    QString halt_cmd = gCoreContext->GetSetting("HaltCommand","");
     68    int ret = -1;
    6769    if (!halt_cmd.isEmpty()) /* Use user specified command if it exists */
    6870    {
    69         myth_system(halt_cmd);
    70     } else if (!DBusHalt()) /* If supported, use DBus to shutdown */
     71        ret = myth_system(halt_cmd);
     72        if (ret != 0)
     73        {
     74            VERBOSE(VB_IMPORTANT, "User defined HaltCommand failed, falling back to alternative methods.");
     75        }
     76    }
     77    if (ret != 0 && !DBusHalt()) /* If supported, use DBus to shutdown */
    7178    {
    7279        myth_system("sudo /sbin/halt -p");
    7380    }
     
    120127{
    121128
    122129    QString reboot_cmd = gCoreContext->GetSetting("RebootCommand","");
     130    int ret = -1;
    123131    if (!reboot_cmd.isEmpty()) /* Use user specified command if it exists */
    124132    {
    125         myth_system(reboot_cmd);
    126     } else if (!DBusReboot()) /* If supported, use DBus to reboot */
     133        ret = myth_system(reboot_cmd);
     134        if (ret != 0)
     135        {
     136            VERBOSE(VB_IMPORTANT, "User defined RebootCommand failed, falling back to alternative methods.");
     137        }
     138    }
     139    if (ret != 0 && !DBusReboot()) /* If supported, use DBus to reboot */
    127140    {
    128141        myth_system("sudo /sbin/reboot");
    129142    }