--- a/src/relpipe-out-chart.cpp Sun Sep 30 18:34:34 2018 +0200
+++ b/src/relpipe-out-chart.cpp Sun Sep 30 20:54:35 2018 +0200
@@ -15,6 +15,11 @@
using namespace relpipe::cli;
using namespace relpipe::reader;
+// signal/slot parameters must be declared here and registered with qRegisterMetaType()
+
+Q_DECLARE_METATYPE(string_t)
+Q_DECLARE_METATYPE(std::vector<AttributeMetadata>)
+
class RelationalReaderThread : public QThread {
private:
std::shared_ptr<RelationalReader> reader;
@@ -48,13 +53,23 @@
RelpipeChartMainWindow window;
window.show();
- QtRelationalReaderStringHadler handler(&app, &window);
+ RelationalReaderThread t(reader);
+
+ // Proxy that passes calls from the background thread to the GUI thread using signal-slot mechanism:
+ QtRelationalReaderStringHadler handler(&t); // &t instead of handler.moveToThread(&t); // QObject::moveToThread: Cannot move objects with a parent
+
+ // see Q_DECLARE_METATYPE above
+ qRegisterMetaType<string_t>();
+ qRegisterMetaType<std::vector < AttributeMetadata >> ();
+
+ QObject::connect(&handler, &QtRelationalReaderStringHadler::startRelationReceived, &window, &RelpipeChartMainWindow::startRelation, Qt::ConnectionType::QueuedConnection);
+ QObject::connect(&handler, &QtRelationalReaderStringHadler::attributeReceived, &window, &RelpipeChartMainWindow::attribute, Qt::ConnectionType::QueuedConnection);
+ QObject::connect(&handler, &QtRelationalReaderStringHadler::endOfPipeReceived, &window, &RelpipeChartMainWindow::endOfPipe, Qt::ConnectionType::QueuedConnection);
+
reader->addHandler(&handler);
// Start background thread
- RelationalReaderThread t(reader);
t.start();
- // ---
int qtResultCode = app.exec();