Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issues #550 and #553 #580

Merged
merged 1 commit into from
Nov 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qucs-core/src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# include <config.h>
#endif

#include <stdio.h>

#include <stdlib.h>
#include <stdarg.h>

Expand Down
2 changes: 1 addition & 1 deletion qucs-core/src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

#define LOG_ERROR 0
#define LOG_STATUS 1

#include <stdio.h>
__BEGIN_DECLS

void logprint (int, const char *, ...);
Expand Down
12 changes: 6 additions & 6 deletions qucs/qucs-lib/qucslib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "displaydialog.h"
#include "symbolwidget.h"


/* Constructor setups the GUI. */
QucsLib::QucsLib()
{
Expand Down Expand Up @@ -112,6 +111,7 @@ QucsLib::QucsLib()
CompList = new QListWidget();
connect(CompList, SIGNAL(itemActivated(QListWidgetItem*)), SLOT(slotShowComponent(QListWidgetItem*)));
connect(CompList,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),SLOT(slotShowComponent(QListWidgetItem*)));
connect(CompList, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(slotShowComponent(QListWidgetItem*)));

CompSearch = new QLineEdit(this);
CompSearch->setPlaceholderText(tr("Search Lib Components"));
Expand Down Expand Up @@ -458,7 +458,6 @@ void QucsLib::slotSearchClear()
// ----------------------------------------------------
void QucsLib::slotShowComponent(QListWidgetItem *Item)
{

if(!Item) return;

//QString CompString = LibraryComps.at(CompList->index(Item));
Expand All @@ -468,6 +467,7 @@ void QucsLib::slotShowComponent(QListWidgetItem *Item)
CompDescr->append("Library: " + LibName);
CompDescr->append("----------------------------");


// FIXME: here we assume that LibName is the same as the actual filename...
int i = Library->findText(LibName);

Expand Down Expand Up @@ -510,11 +510,11 @@ void QucsLib::slotShowComponent(QListWidgetItem *Item)
QMessageBox::critical(this, tr("Error"), tr("Library is corrupt."));
return;
}
if(!content.isEmpty())
Symbol->setSymbol(content, LibName, Item->text());
else if(!DefaultSymbol.isEmpty()) // has library a default symbol ?
Symbol->setSymbol(DefaultSymbol, LibName, Item->text());


Symbol->setSymbol(content, LibName, Item->text());


// change currently selected category, so the user will
// learn where the component comes from
Library->setCurrentIndex(i);
Expand Down
23 changes: 23 additions & 0 deletions qucs/qucs-lib/symbolwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,29 @@ int SymbolWidget::createSymbol(const QString& Lib_, const QString& Comp_)
int SymbolWidget::setSymbol( QString& SymbolString,
const QString& Lib_, const QString& Comp_)
{
if (SymbolString.isEmpty())//Whenever SymbolString is empty, it tries to load the default symbol
{
//Load the default symbol for the current Qucs library
ComponentLibrary parsedlib;
QString libpath = QucsSettings.LibDir + Lib_ + ".lib";
int result = parseComponentLibrary (libpath, parsedlib);

switch (result)//Check if the library was properly loaded
{
case QUCS_COMP_LIB_IO_ERROR:
QMessageBox::critical(0, tr ("Error"), tr("Cannot open \"%1\".").arg (libpath));
return -1;
case QUCS_COMP_LIB_CORRUPT:
QMessageBox::critical(0, tr("Error"), tr("Library is corrupt."));
return -1;
default:
break;
}

// copy the contents of default symbol section to a string
SymbolString = parsedlib.defaultSymbol;
}

Arcs.clear();
Lines.clear();
Rects.clear();
Expand Down
1 change: 1 addition & 0 deletions qucs/qucs-lib/symbolwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <QList>
#include <QMouseEvent>
#include <QPaintEvent>
#include <QMessageBox>

#include "element.h"

Expand Down