mirror of
https://github.com/ra3xdh/qucs_s
synced 2025-03-28 21:13:26 +00:00
Move spiceExtensions out of QucsApp, fix crash
With spiceExtensions inside QucsApp we cannot run spicefile from the command line interface. Check if GUI is running before reading the search path lookup (which has to be defined interactively). Netlisting from the command line (for schematics containing spicefile components) is still not working.
This commit is contained in:
parent
ff071e8726
commit
07ad029735
@ -280,7 +280,7 @@ void SpiceDialog::slotButtBrowse()
|
||||
QString s = QFileDialog::getOpenFileName(this,
|
||||
tr("Select a file"),
|
||||
lastDir.isEmpty() ? QString(".") : lastDir,
|
||||
tr("SPICE netlist") + QString(" (") + App->spiceExtensions.join(" ") + QString(");;")
|
||||
tr("SPICE netlist") + QString(" (") + QucsSettings.spiceExtensions.join(" ") + QString(");;")
|
||||
+ tr("All Files") + " (*.*)");
|
||||
|
||||
if(s.isEmpty()) {
|
||||
|
@ -198,10 +198,10 @@ QString SpiceFile::getSubcircuitFile()
|
||||
// which case we use this one
|
||||
QFileInfo schematicFileInfo = containingSchematic->getFileInfo ();
|
||||
|
||||
for (int i = 0; i < QucsMain->spiceExtensions.count (); i++)
|
||||
for (int i = 0; i < QucsSettings.spiceExtensions.count (); i++)
|
||||
{
|
||||
QFileInfo localFIleInfo (schematicFileInfo.canonicalPath ()
|
||||
+ "/" + baseName + QucsMain->spiceExtensions[i]);
|
||||
+ "/" + baseName + QucsSettings.spiceExtensions[i]);
|
||||
if (localFIleInfo.exists ())
|
||||
{
|
||||
// return the subcircuit saved in the same directory
|
||||
@ -217,7 +217,10 @@ QString SpiceFile::getSubcircuitFile()
|
||||
// search the home directory which is always hashed
|
||||
QMutex mutex;
|
||||
mutex.lock();
|
||||
QString hashsearchresult = QucsMain->spiceNameHash.value(baseName);
|
||||
QString hashsearchresult = "";
|
||||
// if GUI is running and has something in the hash
|
||||
if ( (QucsMain != 0) && !QucsMain->spiceNameHash.isEmpty() )
|
||||
hashsearchresult = QucsMain->spiceNameHash.value(baseName);
|
||||
mutex.unlock();
|
||||
|
||||
if (hashsearchresult.isEmpty())
|
||||
|
@ -288,6 +288,8 @@ int doNetlist(QString schematic, QString netlist)
|
||||
if(SimPorts < -5) {
|
||||
NetlistFile.close();
|
||||
fprintf(stderr, "Error: Could not prepare the netlist...\n");
|
||||
/// \todo better handling for error/warnings
|
||||
qCritical() << ErrText->toPlainText();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,9 @@ struct tQucsSettings {
|
||||
// registered filename extensions with program to open the file
|
||||
QStringList FileTypes;
|
||||
|
||||
// List of extensions used for spice files
|
||||
QStringList spiceExtensions;
|
||||
|
||||
unsigned int numRecentDocs;
|
||||
QStringList RecentDocs;
|
||||
|
||||
|
@ -120,7 +120,7 @@ QucsApp::QucsApp()
|
||||
{
|
||||
setWindowTitle("Qucs " PACKAGE_VERSION);
|
||||
|
||||
spiceExtensions << "*.sp" << "*.cir" << "*.spc" << "*.spi";
|
||||
QucsSettings.spiceExtensions << "*.sp" << "*.cir" << "*.spc" << "*.spi";
|
||||
|
||||
QucsFileFilter =
|
||||
tr("Schematic") + " (*.sch);;" +
|
||||
@ -130,7 +130,7 @@ QucsApp::QucsApp()
|
||||
tr("Verilog Sources") + " (*.v);;" +
|
||||
tr("Verilog-A Sources") + " (*.va);;" +
|
||||
tr("Octave Scripts") + " (*.m *.oct);;" +
|
||||
tr("Spice Files") + QString(" (") + spiceExtensions.join(" ") + QString(");;") +
|
||||
tr("Spice Files") + QString(" (") + QucsSettings.spiceExtensions.join(" ") + QString(");;") +
|
||||
tr("Any File")+" (*)";
|
||||
|
||||
updateSchNameHash();
|
||||
@ -2716,7 +2716,7 @@ void QucsApp::updateSpiceNameHash(void)
|
||||
foreach (QString qucspath, qucsPathList) {
|
||||
QDir thispath(qucspath);
|
||||
// get all the schematic files in the directory
|
||||
QFileInfoList spicefilesList = thispath.entryInfoList( spiceExtensions, QDir::Files );
|
||||
QFileInfoList spicefilesList = thispath.entryInfoList( QucsSettings.spiceExtensions, QDir::Files );
|
||||
// put each one in the hash table with the unique key the base name of
|
||||
// the file, note this will overwrite the value if the key already exists
|
||||
foreach (QFileInfo spicefile, spicefilesList) {
|
||||
@ -2727,7 +2727,7 @@ void QucsApp::updateSpiceNameHash(void)
|
||||
|
||||
// finally check the home/working directory
|
||||
QDir thispath(QucsSettings.QucsWorkDir);
|
||||
QFileInfoList spicefilesList = thispath.entryInfoList( spiceExtensions, QDir::Files );
|
||||
QFileInfoList spicefilesList = thispath.entryInfoList( QucsSettings.spiceExtensions, QDir::Files );
|
||||
// put each one in the hash table with the unique key the base name of
|
||||
// the file, note this will overwrite the value if the key already exists
|
||||
foreach (QFileInfo spicefile, spicefilesList) {
|
||||
|
@ -70,7 +70,6 @@ public:
|
||||
|
||||
QString ProjName; // name of the project, that is open
|
||||
QHash<QString,QString> schNameHash; // QHash for the schematic files lookup
|
||||
QStringList spiceExtensions; // List of extensions used for spice files
|
||||
QHash<QString,QString> spiceNameHash; // QHash for the spice files lookup
|
||||
|
||||
QLineEdit *editText; // for edit component properties on schematic
|
||||
|
Loading…
x
Reference in New Issue
Block a user