Browse Source

Use QIODevice::Text when opening text devices for proper \n translations.

Sascha Zelzer 12 years ago
parent
commit
0f3eaf31c0

+ 1 - 1
Libs/CommandLineModules/Backend/LocalProcess/ctkCmdLineModuleProcessTask.cpp

@@ -83,7 +83,7 @@ void ctkCmdLineModuleProcessTask::run()
   QObject::connect(&process, SIGNAL(finished(int)), &localLoop, SLOT(quit()));
   QObject::connect(&process, SIGNAL(error(QProcess::ProcessError)), &localLoop, SLOT(quit()));
 
-  process.start(d->Location, d->Args);
+  process.start(d->Location, d->Args, QIODevice::ReadOnly | QIODevice::Text);
 
   ctkCmdLineModuleProcessWatcher progressWatcher(process, d->Location, *this);
   Q_UNUSED(progressWatcher)

+ 4 - 5
Libs/CommandLineModules/Testing/Modules/TestBed/ctkCmdLineModuleTestBed.cpp

@@ -67,8 +67,8 @@ int main(int argc, char* argv[])
   parser.addArgument("exitCrash", "", QVariant::Bool, "Force crash", false);
   parser.addArgument("exitTime", "", QVariant::Int, "Exit time", 0);
   parser.addArgument("errorText", "", QVariant::String, "Error text printed at the end");
-  QTextStream out(stdout, QIODevice::WriteOnly);
-  QTextStream err(stderr, QIODevice::WriteOnly);
+  QTextStream out(stdout, QIODevice::WriteOnly | QIODevice::Text);
+  QTextStream err(stderr, QIODevice::WriteOnly | QIODevice::Text);
 
   // Parse the command line arguments
   bool ok = false;
@@ -104,8 +104,7 @@ int main(int argc, char* argv[])
   bool exitCrash = parsedArgs["exitCrash"].toBool();
   QString errorText = parsedArgs["errorText"].toString();
 
-  err << "A superficial error message.\n";
-  err.flush();
+  err << "A superficial error message." << endl;
 
   // sleep 500ms to give the "errorReady" signal a chance
   sleep_ms(500);
@@ -158,7 +157,7 @@ int main(int argc, char* argv[])
     // print the first output
     if (output != "dummy")
     {
-      out << output; endl(out);
+      out << output << endl;
       // report progress
       out << "<filter-progress>" << (i+1)*progressStep << "</filter-progress>\n";
     }