Skip to content

Commit 17340cc

Browse files
committed
Fix Qt 6.9 compatibility: Replace qt_error_string() with enum mapping
The internal Qt function qt_error_string() was removed in Qt 6.9. This commit replaces it with an idiomatic switch statement that maps QFileDevice::FileError enum values to human-readable strings. - Uses tr() for localization support - Provides clear error messages (e.g., "Permissions error" vs error codes) - Standard C++ approach when Qt enums aren't Q_ENUM-registered - All FileError cases covered with default fallback Tested with Qt 6.9.3 on macOS arm64.
1 parent 8832098 commit 17340cc

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/NotepadNext/dialogs/MainWindow.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1877,7 +1877,29 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor)
18771877
void MainWindow::showSaveErrorMessage(ScintillaNext *editor, QFileDevice::FileError error)
18781878
{
18791879
const QString name = editor->isFile() ? editor->getFilePath() : editor->getName();
1880-
QMessageBox::warning(this, tr("Error Saving File"), tr("An error occurred when saving <b>%1</b><br><br>Error: %2").arg(name, qt_error_string(error)));
1880+
1881+
// Map error code to human-readable string
1882+
QString errorString;
1883+
switch (error) {
1884+
case QFileDevice::ReadError: errorString = tr("Read error"); break;
1885+
case QFileDevice::WriteError: errorString = tr("Write error"); break;
1886+
case QFileDevice::FatalError: errorString = tr("Fatal error"); break;
1887+
case QFileDevice::ResourceError: errorString = tr("Resource error"); break;
1888+
case QFileDevice::OpenError: errorString = tr("Open error"); break;
1889+
case QFileDevice::AbortError: errorString = tr("Abort error"); break;
1890+
case QFileDevice::TimeOutError: errorString = tr("Timeout error"); break;
1891+
case QFileDevice::UnspecifiedError: errorString = tr("Unspecified error"); break;
1892+
case QFileDevice::RemoveError: errorString = tr("Remove error"); break;
1893+
case QFileDevice::RenameError: errorString = tr("Rename error"); break;
1894+
case QFileDevice::PositionError: errorString = tr("Position error"); break;
1895+
case QFileDevice::ResizeError: errorString = tr("Resize error"); break;
1896+
case QFileDevice::PermissionsError: errorString = tr("Permissions error"); break;
1897+
case QFileDevice::CopyError: errorString = tr("Copy error"); break;
1898+
default: errorString = tr("Unknown error (%1)").arg(static_cast<int>(error)); break;
1899+
}
1900+
1901+
QMessageBox::warning(this, tr("Error Saving File"),
1902+
tr("An error occurred when saving <b>%1</b><br><br>Error: %2").arg(name, errorString));
18811903
}
18821904

18831905
void MainWindow::showEditorZoomLevelIndicator()

0 commit comments

Comments
 (0)