summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleks Kissinger <aleks0@gmail.com>2018-12-15 11:13:23 +0100
committerAleks Kissinger <aleks0@gmail.com>2018-12-15 11:13:23 +0100
commit9ad4adf9207d3cbda6b92802b91f0435b74d2029 (patch)
tree98bd914664b41538b791007e1524af3894dfdaef /src
parentf7e24d9818726629aa5cb524cf2199b688f6b144 (diff)
parentd6c0003f7589e83c8f9ac6734f9b27554358a9f5 (diff)
Merge branch 'master' into poppler
Diffstat (limited to 'src')
-rw-r--r--src/data/edge.cpp14
-rw-r--r--src/data/edge.h1
-rw-r--r--src/data/graph.cpp3
-rw-r--r--src/data/graphelementdata.cpp6
-rw-r--r--src/data/graphelementdata.h2
-rw-r--r--src/data/node.cpp9
-rw-r--r--src/data/node.h1
-rw-r--r--src/data/tikzdocument.cpp13
-rw-r--r--src/data/tikzdocument.h1
-rw-r--r--src/main.cpp12
-rw-r--r--src/tikzit.cpp6
-rw-r--r--src/tikzit.h1
12 files changed, 20 insertions, 49 deletions
diff --git a/src/data/edge.cpp b/src/data/edge.cpp
index 0ae566b..a9acd85 100644
--- a/src/data/edge.cpp
+++ b/src/data/edge.cpp
@@ -26,7 +26,7 @@
Edge::Edge(Node *s, Node *t, QObject *parent) :
QObject(parent), _source(s), _target(t)
{
- _data = new GraphElementData();
+ _data = new GraphElementData(this);
_edgeNode = 0;
_dirty = true;
@@ -47,12 +47,6 @@ Edge::Edge(Node *s, Node *t, QObject *parent) :
updateControls();
}
-Edge::~Edge()
-{
- delete _data;
- delete _edgeNode;
-}
-
/*!
* @brief Edge::copy makes a deep copy of an edge.
* @param nodeTable is an optional pointer to a table mapping the old source/target
@@ -103,8 +97,9 @@ GraphElementData *Edge::data() const
void Edge::setData(GraphElementData *data)
{
- delete _data;
+ GraphElementData *oldData = _data;
_data = data;
+ oldData->deleteLater();
setAttributesFromData();
}
@@ -148,8 +143,9 @@ Node *Edge::edgeNode() const
void Edge::setEdgeNode(Node *edgeNode)
{
- if (_edgeNode != 0) delete _edgeNode;
+ Node *oldEdgeNode = _edgeNode;
_edgeNode = edgeNode;
+ if (oldEdgeNode != 0) oldEdgeNode->deleteLater();
}
bool Edge::hasEdgeNode()
diff --git a/src/data/edge.h b/src/data/edge.h
index ad71364..5d26b3e 100644
--- a/src/data/edge.h
+++ b/src/data/edge.h
@@ -31,7 +31,6 @@ class Edge : public QObject
Q_OBJECT
public:
explicit Edge(Node *s, Node *t, QObject *parent = 0);
- ~Edge();
Edge *copy(QMap<Node *, Node *> *nodeTable = 0);
Node *source() const;
diff --git a/src/data/graph.cpp b/src/data/graph.cpp
index bba2061..da7b345 100644
--- a/src/data/graph.cpp
+++ b/src/data/graph.cpp
@@ -152,8 +152,9 @@ GraphElementData *Graph::data() const
void Graph::setData(GraphElementData *data)
{
- delete _data;
+ GraphElementData *oldData = _data;
_data = data;
+ oldData->deleteLater();
}
const QVector<Node*> &Graph::nodes()
diff --git a/src/data/graphelementdata.cpp b/src/data/graphelementdata.cpp
index 810ebd6..f743bc5 100644
--- a/src/data/graphelementdata.cpp
+++ b/src/data/graphelementdata.cpp
@@ -23,18 +23,12 @@
GraphElementData::GraphElementData(QVector<GraphElementProperty> init, QObject *parent) : QAbstractItemModel(parent)
{
- root = new GraphElementProperty();
_properties = init;
}
GraphElementData::GraphElementData(QObject *parent) : QAbstractItemModel(parent) {
- root = new GraphElementProperty();
}
-GraphElementData::~GraphElementData()
-{
- delete root;
-}
GraphElementData *GraphElementData::copy()
{
diff --git a/src/data/graphelementdata.h b/src/data/graphelementdata.h
index 23f0466..b1311d7 100644
--- a/src/data/graphelementdata.h
+++ b/src/data/graphelementdata.h
@@ -34,7 +34,6 @@ public:
explicit GraphElementData(QVector<GraphElementProperty> init,
QObject *parent = 0);
explicit GraphElementData(QObject *parent = 0);
- ~GraphElementData();
GraphElementData *copy();
void setProperty(QString key, QString value);
void unsetProperty(QString key);
@@ -78,7 +77,6 @@ public slots:
private:
QVector<GraphElementProperty> _properties;
- GraphElementProperty *root;
};
#endif // GRAPHELEMENTDATA_H
diff --git a/src/data/node.cpp b/src/data/node.cpp
index 75acd00..8ec5e9b 100644
--- a/src/data/node.cpp
+++ b/src/data/node.cpp
@@ -23,15 +23,11 @@
Node::Node(QObject *parent) : QObject(parent), _tikzLine(-1)
{
- _data = new GraphElementData();
+ _data = new GraphElementData(this);
_style = noneStyle;
_data->setProperty("style", "none");
}
-Node::~Node()
-{
- delete _data;
-}
Node *Node::copy() {
Node *n1 = new Node();
@@ -81,8 +77,9 @@ GraphElementData *Node::data() const
void Node::setData(GraphElementData *data)
{
- delete _data;
+ GraphElementData *oldData = _data;
_data = data;
+ oldData->deleteLater();
}
QString Node::styleName() const
diff --git a/src/data/node.h b/src/data/node.h
index 490393d..c40627b 100644
--- a/src/data/node.h
+++ b/src/data/node.h
@@ -31,7 +31,6 @@ class Node : public QObject
Q_OBJECT
public:
explicit Node(QObject *parent = 0);
- ~Node();
Node *copy();
diff --git a/src/data/tikzdocument.cpp b/src/data/tikzdocument.cpp
index 24a793b..863f1fd 100644
--- a/src/data/tikzdocument.cpp
+++ b/src/data/tikzdocument.cpp
@@ -34,16 +34,10 @@ TikzDocument::TikzDocument(QObject *parent) : QObject(parent)
_parseSuccess = true;
_fileName = "";
_shortName = "";
- _undoStack = new QUndoStack();
+ _undoStack = new QUndoStack(this);
_undoStack->setClean();
}
-TikzDocument::~TikzDocument()
-{
- delete _graph;
- delete _undoStack;
-}
-
QUndoStack *TikzDocument::undoStack() const
{
return _undoStack;
@@ -79,11 +73,12 @@ void TikzDocument::open(QString fileName)
_tikz = in.readAll();
file.close();
+ Graph *oldGraph = _graph;
Graph *newGraph = new Graph(this);
TikzAssembler ass(newGraph);
if (ass.parse(_tikz)) {
- delete _graph;
_graph = newGraph;
+ oldGraph->deleteLater();
foreach (Node *n, _graph->nodes()) n->attachStyle();
foreach (Edge *e, _graph->edges()) {
e->attachStyle();
@@ -93,7 +88,7 @@ void TikzDocument::open(QString fileName)
refreshTikz();
setClean();
} else {
- delete newGraph;
+ newGraph->deleteLater();
_parseSuccess = false;
}
}
diff --git a/src/data/tikzdocument.h b/src/data/tikzdocument.h
index fca5434..a5f3534 100644
--- a/src/data/tikzdocument.h
+++ b/src/data/tikzdocument.h
@@ -34,7 +34,6 @@ class TikzDocument : public QObject
Q_OBJECT
public:
explicit TikzDocument(QObject *parent = 0);
- ~TikzDocument();
Graph *graph() const;
void setGraph(Graph *graph);
diff --git a/src/main.cpp b/src/main.cpp
index 99d23e9..7a282e6 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -16,7 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-
/*!
* \file main.cpp
*
@@ -31,21 +30,17 @@
#include <QDebug>
#include <QScreen>
-// #ifdef Q_OS_WIN
-// #include <Windows.h>
-// #endif
-
int main(int argc, char *argv[])
{
// #ifdef Q_OS_WIN
// SetProcessDPIAware();
// #endif
-// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ // QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
// dummy application for detecting DPI
QApplication *a0 = new QApplication(argc, argv);
-// qDebug() << "physical DPI" << QApplication::screens()[0]->physicalDotsPerInch();
+ // qDebug() << "physical DPI" << QApplication::screens()[0]->physicalDotsPerInch();
if (QApplication::screens()[0]->physicalDotsPerInch() >= 100) {
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
@@ -58,14 +53,11 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
a.setQuitOnLastWindowClosed(false);
-
-
tikzit = new Tikzit();
tikzit->init();
qDebug() << a.arguments().length();
-
if (a.arguments().length() > 1) {
tikzit->open(a.arguments()[1]);
}
diff --git a/src/tikzit.cpp b/src/tikzit.cpp
index c9286c9..1c3ba23 100644
--- a/src/tikzit.cpp
+++ b/src/tikzit.cpp
@@ -190,7 +190,7 @@ void Tikzit::newTikzStyles()
if (dialog.exec() && !dialog.selectedFiles().isEmpty()) {
QString fileName = dialog.selectedFiles()[0];
- TikzStyles *st = new TikzStyles;
+ TikzStyles *st = new TikzStyles(this);
if (st->saveStyles(fileName)) {
QFileInfo fi(fileName);
@@ -198,7 +198,7 @@ void Tikzit::newTikzStyles()
_styleFilePath = fi.absoluteFilePath();
settings.setValue("previous-tikzstyles-file", fileName);
settings.setValue("previous-tikzstyles-path", fi.absolutePath());
- delete _styles;
+ _styles->deleteLater();
_styles = st;
foreach (MainWindow *w, _windows) {
@@ -310,7 +310,7 @@ bool Tikzit::loadStyles(QString fileName)
if (st->loadStyles(fileName)) {
_styleFile = fi.fileName();
_styleFilePath = fi.absoluteFilePath();
- delete _styles;
+ _styles->deleteLater();
_styles = st;
foreach (MainWindow *w, _windows) {
diff --git a/src/tikzit.h b/src/tikzit.h
index d36a940..5fed22c 100644
--- a/src/tikzit.h
+++ b/src/tikzit.h
@@ -80,6 +80,7 @@
#define GRID_SEP 10
#define GRID_SEPF 10.0f
+
inline QPointF toScreen(QPointF src)
{ src.setY(-src.y()); src *= GLOBAL_SCALEF; return src; }