Fix rendering of documents that have a locale different than the system's locale

svn path=/trunk/kdenlive/; revision=5869
parent 459897cc
......@@ -31,6 +31,7 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
QStringList preargs;
QString locale;
int in = -1;
int out = -1;
if (args.count() >= 7) {
......@@ -47,6 +48,10 @@ int main(int argc, char **argv)
usekuiserver = true;
args.removeFirst();
}
if (QString(args.at(0)).startsWith("-locale:")) {
locale = QString(args.at(0)).section(':', 1);
args.removeFirst();
}
if (args.at(0).startsWith("in="))
in = args.takeFirst().section('=', -1).toInt();
if (args.at(0).startsWith("out="))
......@@ -86,6 +91,7 @@ int main(int argc, char **argv)
qDebug() << "//STARTING RENDERING: " << erase << "," << usekuiserver << "," << render << "," << profile << "," << rendermodule << "," << player << "," << src << "," << dest << "," << preargs << "," << args << "," << in << "," << out ;
RenderJob *job = new RenderJob(doerase, usekuiserver, render, profile, rendermodule, player, src, dest, preargs, args, in, out);
if (!locale.isEmpty()) job->setLocale(locale);
job->start();
if (dualpass) {
if (vprelist.size()>1)
......@@ -97,9 +103,10 @@ int main(int argc, char **argv)
app.exec();
} else {
fprintf(stderr, "Kdenlive video renderer for MLT.\nUsage: "
"kdenlive_render [-erase] [-kuiserver] [in=pos] [out=pos] [render] [profile] [rendermodule] [player] [src] [dest] [[arg1] [arg2] ...]\n"
"kdenlive_render [-erase] [-kuiserver] [-locale:LOCALE] [in=pos] [out=pos] [render] [profile] [rendermodule] [player] [src] [dest] [[arg1] [arg2] ...]\n"
" -erase: if that parameter is present, src file will be erased at the end\n"
" -kuiserver: if that parameter is present, use KDE job tracker\n"
" -locale:LOCALE : set a locale for rendering. For example, -locale:fr_FR.UTF-8 will use a french locale (comma as numeric separator)\n"
" in=pos: start rendering at frame pos\n"
" out=pos: end rendering at frame pos\n"
" render: path to MLT melt renderer\n"
......
......@@ -124,6 +124,19 @@ RenderJob::~RenderJob()
}
}
void RenderJob::setLocale(const QString &locale)
{
#if QT_VERSION >= 0x040600
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert("LC_NUMERIC", locale);
m_renderProcess->setProcessEnvironment(env);
#else
QStringList env = QProcess::systemEnvironment();
env << QString("LC_NUMERIC=%1").arg(locale);
m_renderProcess->setEnvironment(env);
#endif
}
void RenderJob::slotAbort(const QString& url)
{
if (m_dest == url) slotAbort();
......
......@@ -36,6 +36,7 @@ class RenderJob : public QObject
public:
RenderJob(bool erase, bool usekuiserver, const QString& renderer, const QString& profile, const QString& rendermodule, const QString& player, const QString& scenelist, const QString& dest, const QStringList& preargs, const QStringList& args, int in = -1, int out = -1);
~RenderJob();
void setLocale(const QString &locale);
public slots:
void start();
......
......@@ -730,6 +730,11 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
if (!scriptExport) render_process_args << "-erase";
if (KdenliveSettings::usekuiserver()) render_process_args << "-kuiserver";
// Set locale for render process if required
if (QLocale().decimalPoint() != QLocale::system().decimalPoint()) {
render_process_args << QString("-locale:%1").arg(QLocale().name());
}
double guideStart = 0;
double guideEnd = 0;
......@@ -743,7 +748,11 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
if (!overlayargs.isEmpty()) render_process_args << "preargs=" + overlayargs.join(" ");
render_process_args << KdenliveSettings::rendererpath() << m_profile.path << item->data(RenderRole).toString();
if (scriptExport)
render_process_args << "$MELT";
else
render_process_args << KdenliveSettings::rendererpath();
render_process_args << m_profile.path << item->data(RenderRole).toString();
if (m_view.play_after->isChecked()) render_process_args << KdenliveSettings::KdenliveSettings::defaultplayerapp();
else render_process_args << "-";
......@@ -836,9 +845,9 @@ void RenderWidget::slotExport(bool scriptExport, int zoneIn, int zoneOut, const
outStream << "SOURCE=" << "\"" + playlistPath + "\"" << "\n";
outStream << "TARGET=" << "\"" + KUrl(dest).url() + "\"" << "\n";
outStream << "RENDERER=" << "\"" + m_renderer + "\"" << "\n";
outStream << "MELT=" << "\"" + render_process_args.takeFirst() + "\"" << "\n";
outStream << "MELT=" << "\"" + KdenliveSettings::rendererpath() + "\"" << "\n";
outStream << "PARAMETERS=" << "\"" + render_process_args.join(" ") + "\"" << "\n";
outStream << "$RENDERER $MELT $PARAMETERS" << "\n" << "\n";
outStream << "$RENDERER $PARAMETERS" << "\n" << "\n";
if (file.error() != QFile::NoError) {
KMessageBox::error(this, i18n("Cannot write to file %1", scriptPath));
file.close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment