Skip to content

Commit fdacce1

Browse files
Entrpidail8859
authored andcommitted
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 0a4cc45 commit fdacce1

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
@@ -1888,7 +1888,29 @@ bool MainWindow::checkFileForModification(ScintillaNext *editor)
18881888
void MainWindow::showSaveErrorMessage(ScintillaNext *editor, QFileDevice::FileError error)
18891889
{
18901890
const QString name = editor->isFile() ? editor->getFilePath() : editor->getName();
1891-
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)));
1891+
1892+
// Map error code to human-readable string
1893+
QString errorString;
1894+
switch (error) {
1895+
case QFileDevice::ReadError: errorString = tr("Read error"); break;
1896+
case QFileDevice::WriteError: errorString = tr("Write error"); break;
1897+
case QFileDevice::FatalError: errorString = tr("Fatal error"); break;
1898+
case QFileDevice::ResourceError: errorString = tr("Resource error"); break;
1899+
case QFileDevice::OpenError: errorString = tr("Open error"); break;
1900+
case QFileDevice::AbortError: errorString = tr("Abort error"); break;
1901+
case QFileDevice::TimeOutError: errorString = tr("Timeout error"); break;
1902+
case QFileDevice::UnspecifiedError: errorString = tr("Unspecified error"); break;
1903+
case QFileDevice::RemoveError: errorString = tr("Remove error"); break;
1904+
case QFileDevice::RenameError: errorString = tr("Rename error"); break;
1905+
case QFileDevice::PositionError: errorString = tr("Position error"); break;
1906+
case QFileDevice::ResizeError: errorString = tr("Resize error"); break;
1907+
case QFileDevice::PermissionsError: errorString = tr("Permissions error"); break;
1908+
case QFileDevice::CopyError: errorString = tr("Copy error"); break;
1909+
default: errorString = tr("Unknown error (%1)").arg(static_cast<int>(error)); break;
1910+
}
1911+
1912+
QMessageBox::warning(this, tr("Error Saving File"),
1913+
tr("An error occurred when saving <b>%1</b><br><br>Error: %2").arg(name, errorString));
18921914
}
18931915

18941916
void MainWindow::showEditorZoomLevelIndicator()

0 commit comments

Comments
 (0)