From 331c5d069e79b387eb8964c546dde8109ccf4798 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Fri, 21 Sep 2018 18:35:24 +0200 Subject: fixed bug with fractional coordinates on linux --- src/data/graph.cpp | 10 ++++++---- src/data/tikzlexer.l | 6 ++++-- src/gui/tikzscene.cpp | 4 ++++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/data/graph.cpp b/src/data/graph.cpp index 7d71ceb..2c9a84e 100644 --- a/src/data/graph.cpp +++ b/src/data/graph.cpp @@ -269,10 +269,12 @@ Graph *Graph::copyOfSubgraphWithNodes(QSet nds) Graph *g = new Graph(); g->setData(_data->copy()); QMap nodeTable; - foreach (Node *n, nds) { - Node *n1 = n->copy(); - nodeTable.insert(n, n1); - g->addNode(n1); + foreach (Node *n, nodes()) { + if (nds.contains(n)) { + Node *n1 = n->copy(); + nodeTable.insert(n, n1); + g->addNode(n1); + } } foreach (Edge *e, edges()) { if (nds.contains(e->source()) && nds.contains(e->target())) { diff --git a/src/data/tikzlexer.l b/src/data/tikzlexer.l index 0a67d1d..0d80467 100644 --- a/src/data/tikzlexer.l +++ b/src/data/tikzlexer.l @@ -90,12 +90,14 @@ FLOAT \-?[0-9]*(\.[0-9]+)? } {FLOAT} { yylval->pt = new QPointF(); - yylval->pt->setX(strtod(yytext,NULL)); + QString s(yytext); + yylval->pt->setX(s.toDouble()); BEGIN(ycoord); } , { } {FLOAT} { - yylval->pt->setY(strtod(yytext,NULL)); + QString s(yytext); + yylval->pt->setY(s.toDouble()); } \) { BEGIN(INITIAL); diff --git a/src/gui/tikzscene.cpp b/src/gui/tikzscene.cpp index 2a37014..1c6f0bb 100644 --- a/src/gui/tikzscene.cpp +++ b/src/gui/tikzscene.cpp @@ -621,6 +621,7 @@ void TikzScene::deleteSelectedItems() void TikzScene::copyToClipboard() { Graph *g = graph()->copyOfSubgraphWithNodes(getSelectedNodes()); + //qDebug() << g->tikz(); QGuiApplication::clipboard()->setText(g->tikz()); delete g; } @@ -641,8 +642,11 @@ void TikzScene::pasteFromClipboard() // attempt to parse whatever's on the clipboard, if we get a // non-empty tikz graph, insert it. if (ass.parse(tikz) && !g->nodes().isEmpty()) { + qDebug() << "CLIPBOARD:" << tikz; + qDebug() << "PARSED:" << g->tikz(); // make sure names in the new subgraph are fresh g->renameApart(graph()); + qDebug() << "FRESH:" << g->tikz(); QRectF srcRect = g->realBbox(); QRectF tgtRect = graph()->realBbox(); -- cgit v1.2.3