Skip to content

Commit 75ee96c

Browse files
committed
fix: Add cancellation handling for writing process
- Implemented cancellation signal connection in main.cpp to notify the QML window. - Added onCancelled function in main.qml to forward cancellation events to the wizard container. - Introduced onWriteCancelled function in WizardContainer.qml to reset writing state and navigate back to the writing step. - Updated WritingStep.qml to ensure proper identification of the writing step for state management.
1 parent a826181 commit 75ee96c

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

src/main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ int main(int argc, char *argv[])
441441
qmlwindow->connect(&imageWriter, SIGNAL(preparationStatusUpdate(QVariant)), qmlwindow, SLOT(onPreparationStatusUpdate(QVariant)));
442442
qmlwindow->connect(&imageWriter, SIGNAL(error(QVariant)), qmlwindow, SLOT(onError(QVariant)));
443443
qmlwindow->connect(&imageWriter, SIGNAL(finalizing()), qmlwindow, SLOT(onFinalizing()));
444+
qmlwindow->connect(&imageWriter, SIGNAL(cancelled()), qmlwindow, SLOT(onCancelled()));
444445
// osListPrepared is handled by wizard OSSelection instead of main window
445446
qmlwindow->connect(&imageWriter, SIGNAL(networkInfo(QVariant)), qmlwindow, SLOT(onNetworkInfo(QVariant)));
446447
qmlwindow->connect(&imageWriter, SIGNAL(selectedDeviceRemoved()), qmlwindow, SLOT(onSelectedDeviceRemoved()));

src/main.qml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,13 @@ ApplicationWindow {
348348
wizardContainer.onFinalizing();
349349
}
350350

351+
function onCancelled() {
352+
// Forward to wizard container to handle write cancellation
353+
if (wizardContainer) {
354+
wizardContainer.onWriteCancelled();
355+
}
356+
}
357+
351358
function onNetworkInfo(msg) {
352359
if (imageWriter.isEmbeddedMode() && wizardContainer) {
353360
wizardContainer.networkInfoText = msg;

src/wizard/WizardContainer.qml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,24 @@ Item {
10991099
}
11001100
}
11011101

1102+
function onWriteCancelled() {
1103+
// Reset write state
1104+
isWriting = false
1105+
1106+
// Navigate back to writing step (which will show the summary since isWriting is false)
1107+
if (currentStep !== stepWriting) {
1108+
jumpToStep(stepWriting)
1109+
}
1110+
1111+
// Reset the writing step's state if it exists
1112+
if (wizardStack.currentItem && wizardStack.currentItem.objectName === "writingStep") {
1113+
wizardStack.currentItem.isWriting = false
1114+
wizardStack.currentItem.cancelPending = false
1115+
wizardStack.currentItem.isFinalising = false
1116+
wizardStack.currentItem.isComplete = false
1117+
}
1118+
}
1119+
11021120
function onDownloadProgress(now, total) {
11031121
// Forward to the WritingStep if currently active
11041122
if (currentStep === stepWriting && wizardStack.currentItem) {

src/wizard/WritingStep.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ImageOptions
1313

1414
WizardStepBase {
1515
id: root
16+
objectName: "writingStep"
1617

1718
required property ImageWriter imageWriter
1819
required property var wizardContainer

0 commit comments

Comments
 (0)