Skip to content

Instantly share code, notes, and snippets.

@guitorri
Created September 19, 2014 12:57
Show Gist options
  • Save guitorri/4c95439e050b878926ab to your computer and use it in GitHub Desktop.
Save guitorri/4c95439e050b878926ab to your computer and use it in GitHub Desktop.
cli_print_recdiagram.patch
diff --git a/qucs/qucs/diagrams/rectdiagram.cpp b/qucs/qucs/diagrams/rectdiagram.cpp
index 5122aab..9cd691c 100644
--- a/qucs/qucs/diagrams/rectdiagram.cpp
+++ b/qucs/qucs/diagrams/rectdiagram.cpp
@@ -129,7 +129,15 @@ int RectDiagram::calcDiagram()
Arcs.clear();
double GridStep, corr, zD, zDstep, GridNum;
- QFontMetrics metrics(((Schematic*)QucsMain->DocumentTab->currentPage())->font()); // get size of text
+ QFont currentFont;
+
+ // only set fonts if GUI is running
+ if ((Schematic*)QucsMain != 0)
+ currentFont = ((Schematic*)QucsMain->DocumentTab->currentPage())->font();
+ else
+ currentFont = QFont("Courier New");
+
+ QFontMetrics metrics(currentFont); // get size of text
y1 = QucsSettings.font.pointSize() + 6;
x1 = 10; // position of label text
diff --git a/qucs/qucs/schematic_file.cpp b/qucs/qucs/schematic_file.cpp
index 1ebf494..cfcd596 100644
--- a/qucs/qucs/schematic_file.cpp
+++ b/qucs/qucs/schematic_file.cpp
@@ -895,10 +895,11 @@ bool Schematic::loadDocument()
if(Line == "<Wires>") {
if(!loadWires(&stream)) { file.close(); return false; } }
else
- if ((Schematic*)QucsMain != 0) { // GUI running, load Diagrams, Paintings
+ /// try loading with CLI
if(Line == "<Diagrams>") {
if(!loadDiagrams(&stream, &DocDiags)) { file.close(); return false; } }
else
+ if ((Schematic*)QucsMain != 0) { // GUI running, load Diagrams, Paintings
if(Line == "<Paintings>") {
if(!loadPaintings(&stream, &DocPaints)) { file.close(); return false; } }
else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment