Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/3dview/gcodeto4d.cpp
Show All 24 Lines | |||||
25 | #include <QVariant> | 25 | #include <QVariant> | ||
26 | #include "fileloader.h" | 26 | #include "fileloader.h" | ||
27 | #include "gcodeto4d.h" | 27 | #include "gcodeto4d.h" | ||
28 | 28 | | |||
29 | GcodeTo4D::GcodeTo4D(QObject *parent) : QObject(parent) | 29 | GcodeTo4D::GcodeTo4D(QObject *parent) : QObject(parent) | ||
30 | { | 30 | { | ||
31 | } | 31 | } | ||
32 | 32 | | |||
33 | GcodeTo4D::~GcodeTo4D() | | |||
34 | { | | |||
35 | } | | |||
36 | | ||||
37 | void GcodeTo4D::read(const QString &url) | 33 | void GcodeTo4D::read(const QString &url) | ||
38 | { | 34 | { | ||
39 | _thread = new QThread; | 35 | _thread = new QThread(this); | ||
40 | QString path = QUrl(url).path(); | 36 | QString path = QUrl(url).path(); | ||
41 | auto fileLoader = new FileLoader(path); | 37 | auto fileLoader = new FileLoader(path); | ||
42 | fileLoader->moveToThread(_thread); | 38 | fileLoader->moveToThread(_thread); | ||
43 | connect(fileLoader, &FileLoader::percentUpdate, this, &GcodeTo4D::percentUpdate); | 39 | connect(fileLoader, &FileLoader::percentUpdate, this, &GcodeTo4D::percentUpdate); | ||
44 | connect(fileLoader, &FileLoader::posFinished, this, &GcodeTo4D::posFinished); | 40 | connect(fileLoader, &FileLoader::posFinished, this, &GcodeTo4D::posFinished); | ||
45 | connect(fileLoader, &FileLoader::posFinished, _thread, &QThread::quit); | 41 | connect(fileLoader, &FileLoader::posFinished, _thread, &QThread::quit); | ||
46 | connect(_thread, &QThread::started, fileLoader, &FileLoader::run); | 42 | connect(_thread, &QThread::started, fileLoader, &FileLoader::run); | ||
47 | connect(_thread, &QThread::finished, fileLoader, &FileLoader::deleteLater); | 43 | connect(_thread, &QThread::finished, fileLoader, &FileLoader::deleteLater); | ||
48 | _thread->start(); | 44 | _thread->start(); | ||
49 | } | 45 | } | ||
50 | 46 | |