Skip to content

Commit

Permalink
Make mythtranscode fail gracefully on file not found
Browse files Browse the repository at this point in the history
Fixes #9427

If a recording doesn't exist, or the recording exists, but is not in the
database, mythtranscode will gracefully refuse to transcode it, rather than
crash.

Also, make the MythContext object be on the stack of main(), such that any exit
from the system will hit the dtor, causing a cleaner shutdown.
  • Loading branch information
Beirdo committed May 31, 2011
1 parent d9c4bd1 commit ca4001d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mythtv/programs/mythtranscode/main.cpp
Expand Up @@ -515,7 +515,8 @@ int main(int argc, char *argv[])
print_verbose_messages = VB_NONE;

// Load the context
gContext = new MythContext(MYTH_BINARY_VERSION);
MythContext context(MYTH_BINARY_VERSION);
gContext = &context;
if (!gContext->Init(false))
{
VERBOSE(VB_IMPORTANT, "Failed to init MythContext, exiting.");
Expand Down Expand Up @@ -625,10 +626,16 @@ int main(int argc, char *argv[])
QString("Couldn't find a recording for filename '%1'")
.arg(infile));
delete pginfo;
pginfo = NULL;
return GENERIC_EXIT_NO_RECORDING_DATA;
}
}

if (!pginfo)
{
VERBOSE(VB_IMPORTANT, "No program info found!");
return GENERIC_EXIT_NO_RECORDING_DATA;
}

if (infile.left(7) == "myth://" && (outfile.isNull() || outfile != "-"))
{
VERBOSE(VB_IMPORTANT, QString("Attempted to transcode %1. "
Expand Down Expand Up @@ -752,7 +759,6 @@ int main(int argc, char *argv[])

transcode->deleteLater();

delete gContext;
return exitcode;
}

Expand Down

0 comments on commit ca4001d

Please sign in to comment.