Repository navigation
fix: show error when print save fails to no-permission dir #452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,13 @@ | |
| #include "MainWindow.h" | ||
| #include "ddlog.h" | ||
|
|
||
| #include <DSpinner> | ||
| #include <DPrintPreviewDialog> | ||
| #include <DWidgetUtil> | ||
| #include <DMessageBox> | ||
|
|
||
| #include <QJsonDocument> | ||
| #include <QJsonObject> | ||
| #include <QStackedWidget> | ||
| #include <QMimeData> | ||
| #include <QUuid> | ||
|
|
@@ -1031,6 +1032,7 @@ | |
|
|
||
| void DocSheet::onPrintRequested(DPrinter *printer, const QVector<int> &pageRange) | ||
| { | ||
| m_printPrinter = printer; | ||
| qCDebug(appLog) << "Print requested for pages:" << pageRange; | ||
| if (pageRange.isEmpty()) { | ||
| qCWarning(appLog) << "Empty page range for printing"; | ||
|
|
@@ -1134,6 +1136,7 @@ | |
|
|
||
| void DocSheet::onPrintRequested(DPrinter *printer) | ||
| { | ||
| m_printPrinter = printer; | ||
| // qCDebug(appLog) << "onPrintRequested"; | ||
| printer->setDocName(QFileInfo(filePath()).fileName()); | ||
|
|
||
|
|
@@ -2082,6 +2085,17 @@ | |
| //图片打印 | ||
| connect(preview, QOverload<DPrinter *>::of(&DPrintPreviewDialog::paintRequested), this, QOverload<DPrinter *>::of(&DocSheet::onPrintRequested)); | ||
| #endif | ||
| m_printPrinter = nullptr; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Earlier preview can crash When two preview dialogs for the same Capture and use each preview's own printer in its accepted handler instead of reading Also at Prompt for AI agentsIn `reader/uiframe/DocSheet.cpp` at line 2089:
**Earlier preview can crash**
When two preview dialogs for the same `DocSheet` remain active and the later one closes first, `m_printPrinter` is shared and reset or overwritten by the later request, so the earlier dialog's accepted handler reads its printer, possibly after deletion, missing its save result or dereferencing a stale pointer and crashing.
Capture and use each preview's own printer in its accepted handler instead of reading `m_printPrinter`.
Also at `reader/uiframe/DocSheet.cpp:1035`, `reader/uiframe/DocSheet.cpp:2091`. |
||
| connect(preview, &QDialog::accepted, this, [this]() { | ||
| if (m_printPrinter && !m_printPrinter->outputFileName().isEmpty()) { | ||
| QString savePath = m_printPrinter->outputFileName(); | ||
| if (!QFile::exists(savePath)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Medium · Save feedback misreports outcomes When the destination exists, a failed write leaves a partial file, a non-permission failure leaves no file, or a volume disconnects after writing, Use the print/write result to decide whether to warn, not file existence. Also at Prompt for AI agentsIn `reader/uiframe/DocSheet.cpp` at line 2093:
**Save feedback misreports outcomes**
When the destination exists, a failed write leaves a partial file, a non-permission failure leaves no file, or a volume disconnects after writing, `QFile::exists(savePath)` suppresses warnings for failed overwrites or partial writes, but warns after a successful write followed by disconnection and labels other missing-output failures as permission problems; users get incorrect save feedback.
Use the print/write result to decide whether to warn, not file existence.
Also at `reader/uiframe/DocSheet.cpp:2095`. |
||
| DMessageBox::warning(this, tr("打印"), tr("保存失败,目标目录可能没有写入权限。")); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| preview->open(); | ||
| qCDebug(appLog) << "onPopPrintDialog end"; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High · Direct-path saves skip detection
When DTK handles a
setPrintFromPath()print without emittingpaintRequested,m_printPrinterstays null because its only assignment is inonPrintRequested; the accepted handler then skips the warning, leaving failed saves on this route silent.Capture the printer independently of
paintRequested, or connect failure detection to the direct-path save operation.Also at
reader/uiframe/DocSheet.cpp:2091.Prompt for AI agents