Skip to content

Commit ab41bef

Browse files
authored
Merge pull request #1 from IMProject/pr-speed-up-firmware-file-selection
Speed up firmware file selection
2 parents dd6a0c1 + b4e8823 commit ab41bef

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

flasher.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void Flasher::init()
9696
connect(this, &Flasher::runLoop, worker, &Worker::doWork);
9797
connect(worker, &Worker::flasherLoop, this, &Flasher::loopHandler);
9898
workerThread.start();
99-
runLoop();
99+
emit runLoop();
100100
}
101101

102102
void Flasher::deinit()
@@ -245,7 +245,7 @@ void Flasher::loopHandler()
245245
}
246246

247247
workerThread.msleep(SLEEP_TIME);
248-
runLoop();
248+
emit runLoop();
249249
}
250250

251251
void Flasher::startFlashingSlot()
@@ -551,7 +551,7 @@ void Flasher::deserialize32(uint8_t* buf, uint32_t* value)
551551
*value |= (uint32_t)(buf[3] << 0u);
552552
}
553553

554-
void Flasher::setFilePath(QString filePath)
554+
void Flasher::setFilePath(const QString& filePath)
555555
{
556556
m_filePath = filePath;
557557
}
@@ -576,3 +576,7 @@ void Flasher::getVersion(void)
576576
emit textInBrowser(gitVersion);
577577
//qInfo() << gitVersion;
578578
}
579+
580+
QThread& Flasher::getWorkerThread() {
581+
return workerThread;
582+
}

flasher.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,11 @@ Q_OBJECT
9797
void closeSerialPort();
9898
void actionOpenFirmwareFile();
9999
void deserialize32(uint8_t* buf, uint32_t* value);
100-
void setFilePath(QString filePath);
100+
void setFilePath(const QString& filePath);
101101
void setFlashWriteAddress(QByteArray setFlashWriteAddress);
102102
void sendFlashCommandToApp(void); //enter in bootlaoder
103103
void getVersion(void);
104+
QThread& getWorkerThread();
104105

105106
signals:
106107
void updateProgress(qint64 dataPosition, qint64 firmwareSize);

mainwindow.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,14 @@ Flasher* MainWindow::getFlasherPtr()
184184

185185
void MainWindow::on_selectFirmware_clicked()
186186
{
187+
m_flasher->getWorkerThread().quit();
188+
187189
QString filePath = QFileDialog::getOpenFileName(this,
188190
tr("Flight control binary"), "",
189191
tr("Binary (*.bin);;All Files (*)"));
190192

193+
m_flasher->init();
194+
191195
m_flasher->setFilePath(filePath);
192196
m_flasher->actionOpenFirmwareFile();
193197
}

0 commit comments

Comments
 (0)