prevent crash if no tab is present.

This commit is contained in:
2025-08-19 18:09:29 +02:00
parent 6449fd120f
commit 6cc736d6a5
2 changed files with 44 additions and 14 deletions

View File

@@ -2593,7 +2593,11 @@ void PTextEdit::musrView()
}
QString cmd = fAdmin->getExecPath() + "/musrview";
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString fln="./";
PSubTextEdit *ce = currentEditor();
if (ce != nullptr)
fln = *fFilenames.find(currentEditor());
QString workDir = QFileInfo(fln).absolutePath();
QStringList arg;
QString str;
@@ -2662,7 +2666,11 @@ void PTextEdit::musrView2Dat()
return;
QString cmd = fAdmin->getExecPath() + "/musrview";
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString fln="./";
PSubTextEdit *ce = currentEditor();
if (ce != nullptr)
fln = *fFilenames.find(currentEditor());
QString workDir = QFileInfo(fln).absolutePath();
QStringList arg;
for (auto it : flns) {
@@ -2729,7 +2737,7 @@ void PTextEdit::musrT0()
}
QString cmd = fAdmin->getExecPath() + "/musrt0";
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString workDir = QFileInfo(*fFilenames.find(currentEditor())).absolutePath();
QStringList arg;
QString str;
@@ -2782,6 +2790,9 @@ void PTextEdit::musrT0()
*/
void PTextEdit::musrFT()
{
PSubTextEdit *ce = currentEditor();
if (ce == nullptr)
return;
PGetMusrFTOptionsDialog *dlg = new PGetMusrFTOptionsDialog(*fFilenames.find( currentEditor() ), fMusrFTPrevCmd, fAdmin->getHelpUrl("musrFT"));
@@ -2903,7 +2914,7 @@ void PTextEdit::musrSetSteps()
#if defined(Q_OS_DARWIN)
cmd = QString("/Applications/musrStep.app/Contents/MacOS/musrStep");
#endif
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString workDir = QFileInfo(*fFilenames.find( currentEditor())).absolutePath();
QStringList arg;
QString str;
@@ -3093,7 +3104,11 @@ void PTextEdit::mupp()
QProcess *proc = new QProcess(this);
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString fln="./";
PSubTextEdit *ce = currentEditor();
if (ce != nullptr)
fln = *fFilenames.find(currentEditor());
QString workDir = QFileInfo(fln).absolutePath();
// make sure that the system environment variables are properly set
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();

View File

@@ -2585,12 +2585,16 @@ void PTextEdit::musrView()
}
QString cmd = fAdmin->getExecPath() + "/musrview";
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString fln="./";
PSubTextEdit *ce = currentEditor();
if (ce != nullptr)
fln = *fFilenames.find(currentEditor());
QString workDir = QFileInfo(fln).absolutePath();
QStringList arg;
QString str;
// file name
str = *fFilenames.find( currentEditor() );
str = fln;
int pos = str.lastIndexOf("/");
if (pos != -1)
str.remove(0, pos+1);
@@ -2650,7 +2654,11 @@ void PTextEdit::musrView2Dat()
return;
QString cmd = fAdmin->getExecPath() + "/musrview";
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString fln="./";
PSubTextEdit *ce = currentEditor();
if (ce != nullptr)
fln = *fFilenames.find(currentEditor());
QString workDir = QFileInfo(fln).absolutePath();
QStringList arg;
for (auto it : flns) {
@@ -2717,12 +2725,12 @@ void PTextEdit::musrT0()
}
QString cmd = fAdmin->getExecPath() + "/musrt0";
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString workDir = QFileInfo(*fFilenames.find(currentEditor())).absolutePath();
QStringList arg;
QString str;
// file name
str = *fFilenames.find( currentEditor() );
str = *fFilenames.find(currentEditor());
int pos = str.lastIndexOf("/");
if (pos != -1)
str.remove(0, pos+1);
@@ -2763,8 +2771,11 @@ void PTextEdit::musrT0()
*/
void PTextEdit::musrFT()
{
PSubTextEdit *ce = currentEditor();
if (ce == nullptr)
return;
PGetMusrFTOptionsDialog *dlg = new PGetMusrFTOptionsDialog(*fFilenames.find( currentEditor() ), fMusrFTPrevCmd, fAdmin->getHelpUrl("musrFT"));
PGetMusrFTOptionsDialog *dlg = new PGetMusrFTOptionsDialog(*fFilenames.find(currentEditor()), fMusrFTPrevCmd, fAdmin->getHelpUrl("musrFT"));
if (dlg == nullptr) {
QMessageBox::critical(this, "ERROR musrFT", "Couldn't invoke musrFT Options Dialog.");
@@ -2877,12 +2888,12 @@ void PTextEdit::musrSetSteps()
#if defined(Q_OS_DARWIN)
cmd = QString("/Applications/musrStep.app/Contents/MacOS/musrStep");
#endif
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString workDir = QFileInfo(*fFilenames.find(currentEditor())).absolutePath();
QStringList arg;
QString str;
// get file name and feed it to the command queue
str = *fFilenames.find( currentEditor() );
str = *fFilenames.find(currentEditor());
int pos = str.lastIndexOf("/");
if (pos != -1)
str.remove(0, pos+1);
@@ -3064,7 +3075,11 @@ void PTextEdit::mupp()
QProcess *proc = new QProcess(this);
QString workDir = QFileInfo(*fFilenames.find( currentEditor() )).absolutePath();
QString fln="./";
PSubTextEdit *ce = currentEditor();
if (ce != nullptr)
fln = *fFilenames.find(currentEditor());
QString workDir = QFileInfo(fln).absolutePath();
// make sure that the system environment variables are properly set
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();