Commit c65e7dbd authored by Sylvain Thery's avatar Sylvain Thery

resolve pb (schnapps/python) of non ascii char on Linux

parent f831db2e
...@@ -33,7 +33,6 @@ bool Surface_Import_Plugin::enable() ...@@ -33,7 +33,6 @@ bool Surface_Import_Plugin::enable()
MapHandlerGen* Surface_Import_Plugin::importMeshFromFile(const QString& nameOfFile) MapHandlerGen* Surface_Import_Plugin::importMeshFromFile(const QString& nameOfFile)
{ {
QString fileName = SCHNApps::noBackSlash(nameOfFile); QString fileName = SCHNApps::noBackSlash(nameOfFile);
QFileInfo fi(fileName); QFileInfo fi(fileName);
......
...@@ -1045,15 +1045,16 @@ bool SCHNApps::loadPythonScriptFromFile(const QString& fileName) ...@@ -1045,15 +1045,16 @@ bool SCHNApps::loadPythonScriptFromFile(const QString& fileName)
return false; return false;
} }
} }
#ifdef WIN32
QFile file(fullName); QFile file(fullName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return false; return false;
QTextStream in(&file); QTextStream in(&file);
m_pythonContext.evalScript(in.readAll()); m_pythonContext.evalScript(in.readAll());
#else
m_pythonContext.evalFile(fullName); // not using eval file because of pb with non ascii char in file name and path
#endif // m_pythonContext.evalFile(fullName);
return true; return true;
} }
...@@ -1162,6 +1163,9 @@ void SCHNApps::pyRecording() ...@@ -1162,6 +1163,9 @@ void SCHNApps::pyRecording()
QString fileName = QFileDialog::getSaveFileName(this, "Save python script", pypath, " python script (*.py)"); QString fileName = QFileDialog::getSaveFileName(this, "Save python script", pypath, " python script (*.py)");
if (fileName.size() != 0) if (fileName.size() != 0)
{ {
if (!fileName.endsWith(".py",Qt::CaseInsensitive))
fileName += ".py";
m_pyRecFile = new QFile(fileName); m_pyRecFile = new QFile(fileName);
if (!m_pyRecFile->open(QIODevice::WriteOnly | QIODevice::Text)) if (!m_pyRecFile->open(QIODevice::WriteOnly | QIODevice::Text))
return; return;
...@@ -1237,6 +1241,9 @@ void SCHNApps::appendPyRecording() ...@@ -1237,6 +1241,9 @@ void SCHNApps::appendPyRecording()
QString fileName = QFileDialog::getSaveFileName(this, "Append python script", pypath, " python script (*.py)"); QString fileName = QFileDialog::getSaveFileName(this, "Append python script", pypath, " python script (*.py)");
if (fileName.size() != 0) if (fileName.size() != 0)
{ {
if (!fileName.endsWith(".py",Qt::CaseInsensitive))
fileName += ".py";
m_pyRecFile = new QFile(fileName); m_pyRecFile = new QFile(fileName);
if (!m_pyRecFile->open(QIODevice::Append | QIODevice::Text)) if (!m_pyRecFile->open(QIODevice::Append | QIODevice::Text))
return; return;
......
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