Skip to content

Commit

Permalink
workaround for running graphviz under Qt5
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jan 15, 2017
1 parent 177f36a commit 5b5189a
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Gui/GraphvizView.cpp
Expand Up @@ -67,14 +67,35 @@ class GraphvizWorker : public QThread {
GraphvizWorker(QObject * parent = 0)
: QThread(parent)
{
#if QT_VERSION < 0x050000
proc.moveToThread(this);
#endif
}

virtual ~GraphvizWorker()
{
#if QT_VERSION >= 0x050000
proc.moveToThread(this);
#endif
}

void setData(const QByteArray & data)
{
str = data;
}

void startThread() {
#if QT_VERSION >= 0x050000
// This doesn't actually run a thread but calls the function
// directly in the main thread.
// This is needed because embedding a QProcess into a QThread
// causes some problems with Qt5.
run();
#else
start();
#endif
}

void run() {
// Write data to process
proc.write(str);
Expand Down Expand Up @@ -210,7 +231,7 @@ void GraphvizView::updateSvgItem(const App::Document &doc)

// Update worker thread, and start it
thread->setData(QByteArray(graphCode.c_str(), graphCode.size()));
thread->start();
thread->startThread();
}

void GraphvizView::svgFileRead(const QByteArray & data)
Expand Down

0 comments on commit 5b5189a

Please sign in to comment.