Skip to content
Permalink
Browse files

Make mythtranscode fail gracefully on file not found

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 ca4001dabf3f4c140ae83effc2c7927ab7fd1352
Showing with 9 additions and 3 deletions.
  1. +9 −3 mythtv/programs/mythtranscode/main.cpp
@@ -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.");
@@ -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. "
@@ -752,7 +759,6 @@ int main(int argc, char *argv[])

transcode->deleteLater();

delete gContext;
return exitcode;
}

0 comments on commit ca4001d

Please sign in to comment.
You can’t perform that action at this time.