Skip to content

Commit

Permalink
better error checking and retrieve script content
Browse files Browse the repository at this point in the history
  • Loading branch information
samamou committed Dec 30, 2024
1 parent c5f6fd2 commit 705f297
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/plugins/score-lib-process/Process/Script/ScriptEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,26 @@ void ScriptDialog::openInExternalEditor()
return;
}

if(!QFile::exists(editorPath))
{
QMessageBox::warning(
this, tr("Error"), tr("the configured external editor does not exist."));
return;
}

QString tempDir = QStandardPaths::writableLocation(QStandardPaths::TempLocation);
QString tempFile = tempDir + "/ossia_script_temp.js";

QFile file(tempFile);
if(!file.open(QIODevice::WriteOnly))
{
QMessageBox::warning(this, tr("Error"), tr("failed to create temporary file."));
return;
}

QTextStream stream(&file);
stream << "Temporary file content for testing.";
QString scriptContent = this->text();
stream << scriptContent;
file.close();

if(!QProcess::startDetached(editorPath, QStringList() << tempFile))
Expand Down

0 comments on commit 705f297

Please sign in to comment.