got rid of direct 'system()' calls wherever possible.
This commit is contained in:
parent
d74588827e
commit
ea841ec186
@ -2185,29 +2185,29 @@ void PTextEdit::musrView()
|
|||||||
fileSave();
|
fileSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString cmd;
|
QString cmd = fAdmin->getExecPath() + "/musrview";
|
||||||
|
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
|
||||||
|
QStringList arg;
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
str = "cd \"" + QFileInfo(*fFilenames.find( currentEditor() )).absolutePath() + "\"; ";
|
// file name
|
||||||
|
|
||||||
str += fAdmin->getExecPath() + "/musrview";
|
|
||||||
cmd = str + " \"";
|
|
||||||
|
|
||||||
str = *fFilenames.find( currentEditor() );
|
str = *fFilenames.find( currentEditor() );
|
||||||
int pos = str.lastIndexOf("/");
|
int pos = str.lastIndexOf("/");
|
||||||
if (pos != -1)
|
if (pos != -1)
|
||||||
str.remove(0, pos+1);
|
str.remove(0, pos+1);
|
||||||
QString numStr;
|
arg << str;
|
||||||
numStr.setNum(fAdmin->getTimeout());
|
|
||||||
cmd += str + "\" --timeout " + numStr;
|
// timeout
|
||||||
|
str.setNum(fAdmin->getTimeout());
|
||||||
|
arg << "--timeout" << str;
|
||||||
|
|
||||||
|
// start with Fourier?
|
||||||
if (fAdmin->getMusrviewShowFourierFlag())
|
if (fAdmin->getMusrviewShowFourierFlag())
|
||||||
cmd += " -f ";
|
arg << "-f";
|
||||||
cmd += " &";
|
|
||||||
|
|
||||||
int status=system(cmd.toLatin1());
|
QProcess proc(this);
|
||||||
|
if (!proc.startDetached(cmd, arg, workDir)) {
|
||||||
if (status != 0) {
|
QMessageBox::critical(this, "ERROR", "**ERROR** musrview process couldn't be launched properly, sorry.");
|
||||||
cerr << "**WARNING** musrView: something went wrong ..." << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2230,20 +2230,26 @@ void PTextEdit::musrT0()
|
|||||||
fileSave();
|
fileSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString cmd;
|
QString cmd = fAdmin->getExecPath() + "/musrt0";
|
||||||
|
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
|
||||||
|
QStringList arg;
|
||||||
QString str;
|
QString str;
|
||||||
|
|
||||||
str = fAdmin->getExecPath() + "/musrt0";
|
// file name
|
||||||
cmd = str + " \"";
|
|
||||||
|
|
||||||
str = *fFilenames.find( currentEditor() );
|
str = *fFilenames.find( currentEditor() );
|
||||||
QString numStr;
|
int pos = str.lastIndexOf("/");
|
||||||
numStr.setNum(fAdmin->getTimeout());
|
if (pos != -1)
|
||||||
cmd += str + "\" --timeout " + numStr + " &";
|
str.remove(0, pos+1);
|
||||||
|
arg << str;
|
||||||
|
|
||||||
int status=system(cmd.toLatin1());
|
// timeout
|
||||||
|
str.setNum(fAdmin->getTimeout());
|
||||||
|
arg << "--timeout" << str;
|
||||||
|
|
||||||
QString fln = *fFilenames.find( currentEditor() );
|
QProcess proc(this);
|
||||||
|
if (!proc.startDetached(cmd, arg, workDir)) {
|
||||||
|
QMessageBox::critical(this, "ERROR", "**ERROR** musrt0 process couldn't be launched properly, sorry.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -2355,16 +2361,44 @@ void PTextEdit::musrSwapMsrMlog()
|
|||||||
fileSave();
|
fileSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QMessageBox::information(0, "INFO", QString("Will now swap files: %1 <-> %2").arg(currentFileName).arg(swapFileName));
|
||||||
|
|
||||||
// swap files
|
// swap files
|
||||||
QString cmd;
|
|
||||||
cmd = QString("cp \"") + currentFileName + QString("\" \"") + tempFileName + QString("\"");
|
// copy currentFile -> tempFile
|
||||||
int status=system(cmd.toLatin1());
|
if (QFile::exists(tempFileName)) {
|
||||||
cmd = QString("cp \"") + swapFileName + QString("\" \"") + currentFileName + QString("\"");
|
if (!QFile::remove(tempFileName)) {
|
||||||
status=system(cmd.toLatin1());
|
QMessageBox::critical(0, "ERROR", QString("failed to remove %1").arg(tempFileName));
|
||||||
cmd = QString("cp \"") + tempFileName + QString("\" \"") + swapFileName + QString("\"");
|
return;
|
||||||
status=system(cmd.toLatin1());
|
}
|
||||||
cmd = QString("rm \"") + tempFileName + QString("\"");
|
}
|
||||||
status=system(cmd.toLatin1());
|
if (!QFile::copy(currentFileName, tempFileName)) {
|
||||||
|
QMessageBox::critical(0, "ERROR", QString("failed to copy %1 -> %2").arg(currentFileName).arg(tempFileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// copy swapFile -> currentFile
|
||||||
|
if (!QFile::remove(currentFileName)) {
|
||||||
|
QMessageBox::critical(0, "ERROR", QString("failed to remove %1").arg(currentFileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!QFile::copy(swapFileName, currentFileName)) {
|
||||||
|
QMessageBox::critical(0, "ERROR", QString("failed to copy %1 -> %2").arg(swapFileName).arg(currentFileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// copy tempFile -> swapFile
|
||||||
|
if (!QFile::remove(swapFileName)) {
|
||||||
|
QMessageBox::critical(0, "ERROR", QString("failed to remove %1").arg(swapFileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!QFile::copy(tempFileName, swapFileName)) {
|
||||||
|
QMessageBox::critical(0, "ERROR", QString("failed to copy %1 -> %2").arg(tempFileName).arg(swapFileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// clean up
|
||||||
|
if (!QFile::remove(tempFileName)) {
|
||||||
|
QMessageBox::critical(0, "ERROR", QString("failed to remove %1").arg(tempFileName));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int currentIdx = fTabWidget->currentIndex();
|
int currentIdx = fTabWidget->currentIndex();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user