Skip to content

Commit

Permalink
Merge pull request #992 from ra3xdh/979_fix
Browse files Browse the repository at this point in the history
Fixed crash when no simulators found on first start
  • Loading branch information
ra3xdh authored Oct 11, 2024
2 parents 77b46ef + 72acdd5 commit 77042de
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion qucs/components/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,7 @@ Component *getComponentFromName(QString &Line, Schematic *p) {

if (!c) {
/// \todo enable user to load partial schematic, skip unknown components
if (QucsMain != 0) {
if (QucsMain != nullptr) {
QMessageBox *msg = new QMessageBox(QMessageBox::Warning, QObject::tr("Warning"),
QObject::tr("Format Error:\nUnknown component!\n"
"%1\n\n"
Expand Down
2 changes: 1 addition & 1 deletion qucs/components/spicefile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ bool SpiceFile::recreateSubNetlist(QString *SpiceFile, QString *FileName)
(*filstream) << NetText;

// only interact with the GUI if it was launched
if (QucsMain) {
if (QucsMain != nullptr) {
QucsMain->statusBar()->showMessage(tr("Converting SPICE file \"%1\".").arg(*SpiceFile), 2000);
}
else
Expand Down
2 changes: 1 addition & 1 deletion qucs/extsimkernels/ngspice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void Ngspice::slotSimulate()
QString ngsp_cmd = cmd_args.at(0);
cmd_args.removeAt(0);
SimProcess->start(ngsp_cmd,cmd_args);
if (QucsMain)
if (QucsMain != nullptr)
emit started();
}

Expand Down
6 changes: 4 additions & 2 deletions qucs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

tQucsSettings QucsSettings;

QucsApp *QucsMain = 0; // the Qucs application itself
QucsApp *QucsMain = nullptr; // the Qucs application itself
QString lastDir; // to remember last directory for several dialogs
QStringList qucsPathList;
VersionTriplet QucsVersion; // Qucs version string
Expand Down Expand Up @@ -179,7 +179,9 @@ bool saveApplSettings()
qs.setItem<QString>("font", QucsSettings.font.toString());
qs.setItem<QString>("appFont", QucsSettings.appFont.toString());
qs.setItem<QString>("textFont", QucsSettings.textFont.toString());
qs.setItem<QByteArray>("MainWindowGeometry", QucsMain->saveGeometry());
if (QucsMain != nullptr) {
qs.setItem<QByteArray>("MainWindowGeometry", QucsMain->saveGeometry());
}

// store LargeFontSize as a string, so it will be also human-readable in the settings file (will be a @Variant() otherwise)
qs.setItem<QString>("LargeFontSize", QString::number(QucsSettings.largeFontSize));
Expand Down
4 changes: 2 additions & 2 deletions qucs/schematic_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ bool Schematic::loadDocument()
QFile file(DocName);
if(!file.open(QIODevice::ReadOnly)) {
/// \todo implement unified error/warning handling GUI and CLI
if (QucsMain)
if (QucsMain != nullptr)
QMessageBox::critical(0, QObject::tr("Error"),
QObject::tr("Cannot load document: ")+DocName);
else
Expand Down Expand Up @@ -1509,7 +1509,7 @@ bool Schematic::throughAllComps(QTextStream *stream, int& countInit,
delete d;
/// \todo implement error/warning message dispatcher for GUI and CLI modes.
QString message = QObject::tr("ERROR: Cannot load subcircuit \"%1\".").arg(s);
if (QucsMain) // GUI is running
if (QucsMain != nullptr) // GUI is running
ErrText->appendPlainText(message);
else // command line
qCritical() << "Schematic::throughAllComps" << message;
Expand Down

0 comments on commit 77042de

Please sign in to comment.