41 CLI cli(argc, argv); |
41 CLI cli(argc, argv); |
42 // TODO: argument name collisions? Filter arguments? Use prefix for Qt? Qt: -title, -style, -geometry |
42 // TODO: argument name collisions? Filter arguments? Use prefix for Qt? Qt: -title, -style, -geometry |
43 QApplication app(argc, argv); |
43 QApplication app(argc, argv); |
44 |
44 |
45 std::shared_ptr<RelationalReader> reader(Factory::create(std::cin)); |
45 std::shared_ptr<RelationalReader> reader(Factory::create(std::cin)); |
46 |
|
47 |
|
48 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
46 int resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; |
49 |
47 |
50 RelpipeChartMainWindow window; |
48 RelpipeChartMainWindow window; |
51 |
|
52 // TODO: remove; just demo |
|
53 QObject::connect(&window, &RelpipeChartMainWindow::signal123, &window, &RelpipeChartMainWindow::slot123); |
|
54 |
|
55 window.show(); |
49 window.show(); |
56 |
50 |
57 QtRelationalReaderStringHadler handler(&app, &window); |
51 QtRelationalReaderStringHadler handler(&app, &window); |
58 reader->addHandler(&handler); |
52 reader->addHandler(&handler); |
59 |
53 |
60 // Start background thread |
54 // Start background thread |
61 RelationalReaderThread t(reader); |
55 RelationalReaderThread t(reader); |
62 t.start(); |
56 t.start(); |
63 // --- |
57 // --- |
64 |
58 |
65 // window.signal123(); |
59 int qtResultCode = app.exec(); |
66 |
60 |
67 app.exec(); |
61 if (qtResultCode == 0) { |
68 //return app.exec(); |
62 resultCode = CLI::EXIT_CODE_SUCCESS; |
|
63 } else { |
|
64 // TODO: report and log Qt errors if any |
|
65 } |
69 |
66 |
70 if (t.isRunning()) { |
67 if (t.isRunning()) { |
71 std::wcerr << L"Background RelationalReader thread is still running → terminate()" << std::endl; |
68 std::wcerr << L"Background RelationalReader thread is still running → terminate()" << std::endl; |
72 t.terminate(); |
69 t.terminate(); |
73 std::wcerr << L"Background RelationalReader thread was terminated → wait()" << std::endl; |
70 std::wcerr << L"Background RelationalReader thread was terminated → wait()" << std::endl; |