From 5b5189a8d69378e4216062bab6932978ce303be7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 16 Jan 2017 00:09:39 +0100 Subject: [PATCH] workaround for running graphviz under Qt5 --- src/Gui/GraphvizView.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Gui/GraphvizView.cpp b/src/Gui/GraphvizView.cpp index 65b3f432dd63..1c95654a17f0 100644 --- a/src/Gui/GraphvizView.cpp +++ b/src/Gui/GraphvizView.cpp @@ -67,7 +67,16 @@ 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) @@ -75,6 +84,18 @@ class GraphvizWorker : public QThread { 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); @@ -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)