From fcb91df81c39e31978a248f1c23e9cbb901ecdde Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 3 Aug 2005 12:41:20 +0000 Subject: [PATCH] Fixed initialization. Also made sure that stdio is only redirected once as the CL args are passed multiple times. --- src/info/gui.cpp | 5 +++-- src/info/mkvinfo.cpp | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/info/gui.cpp b/src/info/gui.cpp index cb3cd84e0..3429e3f5b 100644 --- a/src/info/gui.cpp +++ b/src/info/gui.cpp @@ -52,11 +52,12 @@ bool mi_app::OnInit() { string initial_file; vector args; + + setup(); + #if WXUNICODE int i; - init_mm_stdio(); - for (i = 1; i < argc; i++) args.push_back(string(wxMB(wxString(argv[i])))); #else diff --git a/src/info/mkvinfo.cpp b/src/info/mkvinfo.cpp index 3e04cd988..ad3e6eeb0 100644 --- a/src/info/mkvinfo.cpp +++ b/src/info/mkvinfo.cpp @@ -259,6 +259,7 @@ _show_element(EbmlElement *l, void parse_args(vector args, string &file_name) { + static bool stdio_redirected = false; int i; verbose = 0; @@ -294,9 +295,11 @@ parse_args(vector args, if ((i + 1) == args.size()) mxerror("'%s' is missing the file name.\n", args[i].c_str()); try { - set_mm_stdio(new mm_file_io_c(args[i + 1], MODE_CREATE)); + if (!stdio_redirected) + set_mm_stdio(new mm_file_io_c(args[i + 1], MODE_CREATE)); + stdio_redirected = true; ++i; - } catch(...) { + } catch(mm_io_open_error_c &e) { mxerror("Could not open the file '%s' for directing the output.\n", args[i + 1].c_str()); } @@ -2032,7 +2035,8 @@ console_main(vector args) { int main(int argc, char **argv) { - init_mm_stdio(); + setup(); + return console_main(command_line_utf8(argc, argv)); }