Skip to content

Fix Document::saveAs with QSaveFile - #469

Open
lite-tx wants to merge 2 commits into
QtExcel:masterfrom
lite-tx:codex/issue-443-qsavefile
Open

Fix Document::saveAs with QSaveFile#469
lite-tx wants to merge 2 commits into
QtExcel:masterfrom
lite-tx:codex/issue-443-qsavefile

Conversation

@lite-tx

@lite-tx lite-tx commented Jul 24, 2026

Copy link
Copy Markdown

Summary

  • preserve QSaveFile ownership while allowing QZipWriter to finalize the ZIP archive
  • keep the existing close behavior for other QIODevice implementations
  • document that callers must commit a QSaveFile after Document::saveAs()

QZipWriter::close() must be called to write the ZIP central directory, but it also unconditionally closes its device. Closing a QSaveFile aborts the process because it must be finalized with commit(). The new proxy forwards I/O and seek operations while intercepting only close(), so the caller can commit the completed workbook atomically.

Verification

  • reproduced the original QSaveFile::close called fatal exit on current master
  • verified both pre-opened and unopened QSaveFile instances can save, remain open, commit, and be read back
  • verified existing QFile and QBuffer close behavior and workbook read-back
  • independently validated generated archives with Python zipfile -t
  • built and ran the regression with Qt 5.15.2/MSVC in Debug, Release static, and Release shared configurations
  • built and ran the regression with Qt 6.6.0/MSVC in Release static configuration
  • built and ran TestExcel through qmake/nmake

Fixes #443

@sonarqubecloud

Copy link
Copy Markdown

@lite-tx
lite-tx marked this pull request as ready for review July 24, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Application aborts when QSaveFile is passed to Document::saveAs(QIODevice *device)

1 participant