[kgraphviewer-devel] [KGraphViewer/libkgraphviz] 1c43805: Properly init graphviz lib by calling aginitlib()

Kevin Funk krf at electrostorm.net
Tue Dec 21 16:40:27 CET 2010


commit 1c43805af3217ce1f90694ab846e0f5caea0a696
branch libkgraphviz
Author: Kevin Funk <krf at electrostorm.net>
Date:   Mon Dec 20 18:04:27 2010 +0100

    Properly init graphviz lib by calling aginitlib()

diff --git a/src/kgraphviz/dotgraph.cpp b/src/kgraphviz/dotgraph.cpp
index 82e1ef1..b9c9c90 100644
--- a/src/kgraphviz/dotgraph.cpp
+++ b/src/kgraphviz/dotgraph.cpp
@@ -49,6 +49,8 @@
 #include <QMutexLocker>
 #include <QUuid>
 
+#define AGINIT() aginitlib(sizeof(Agraph_t),sizeof(Agnode_t),sizeof(Agedge_t))
+
 using namespace boost;
 using namespace boost::spirit::classic;
 
@@ -58,7 +60,8 @@ using namespace KGraphViz;
 
 const distinct_parser<> keyword_p("0-9a-zA-Z_");
 
-DotGraphPrivate::DotGraphPrivate() :
+DotGraphPrivate::DotGraphPrivate(DotGraph* parent) :
+  q_ptr(parent),
   m_width(0.0), m_height(0.0),m_scale(1.0),
   m_directed(true), m_strict(false),
   m_horizCellFactor(0), m_vertCellFactor(0),
@@ -66,28 +69,26 @@ DotGraphPrivate::DotGraphPrivate() :
   m_useLibrary(false),
   m_readWrite(false)
 {
-}
+  AGINIT();
 
-DotGraphPrivate::~DotGraphPrivate()
-{
+  Q_Q(DotGraph);
+  q->connect(&m_graphIO, SIGNAL(finished()), q, SIGNAL(readyToDisplay()));
 }
 
-void DotGraphPrivate::init()
+DotGraphPrivate::~DotGraphPrivate()
 {
-  Q_Q(DotGraph);
-  q->connect(&m_graphIO, SIGNAL(finished()), q, SIGNAL(readyToDisplay()));
 }
 
 DotGraph::DotGraph() :
   GraphElement(),
-  d_ptr(new DotGraphPrivate)
+  d_ptr(new DotGraphPrivate(this))
 {
   setId("unnamed");
 }
 
 DotGraph::DotGraph(const QString& layoutCommand, const QString& fileName) :
   GraphElement(),
-  d_ptr(new DotGraphPrivate)
+  d_ptr(new DotGraphPrivate(this))
 {
   setId("unnamed");
 
diff --git a/src/kgraphviz/dotgraph_p.h b/src/kgraphviz/dotgraph_p.h
index cb01e2e..c46fcb3 100644
--- a/src/kgraphviz/dotgraph_p.h
+++ b/src/kgraphviz/dotgraph_p.h
@@ -28,11 +28,9 @@ namespace KGraphViz
 class DotGraphPrivate
 {
 public:
-  explicit DotGraphPrivate();
+  explicit DotGraphPrivate(DotGraph* parent);
   virtual ~DotGraphPrivate();
 
-  void init();
-
   unsigned int cellNumber(int x, int y) const;
   void computeCells();
 


More information about the kgraphviewer-devel mailing list