Skip to content

Commit

Permalink
Fix renaming of classes in Windows (OpenModelica#12594)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Jun 17, 2024
1 parent b290aeb commit 26dbf74
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions OMEdit/OMEditLIB/Modeling/LibraryTreeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4694,6 +4694,15 @@ bool LibraryWidget::saveFile(QString fileName, QString contents)
default:
break;
}
/* Issue #12567
* Try to remove the file if it already exists since Windows can't handle case sensitive file names.
* So if we already have `a.mo` and wants to save it as `A.mo` then the file is saved with new contents but the filename remains `a.mo`
*/
#ifdef Q_OS_WIN
if (QFile::exists(fileName)) {
QFile::remove(fileName);
}
#endif
// open the file for writing
QFile file(fileName);
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
Expand Down Expand Up @@ -5096,7 +5105,12 @@ bool LibraryWidget::saveModelicaLibraryTreeItemFolder(LibraryTreeItem *pLibraryT
QString currentLine = textStream.readLine();
bool classExists = false;
for (int i = 0; i < pLibraryTreeItem->childrenSize(); i++) {
// Issue #12567. Compare case insensitive on Windows as `a` and `A` means the same thing.
#ifdef Q_OS_WIN
if (pLibraryTreeItem->child(i)->getName().compare(currentLine, Qt::CaseInsensitive) == 0) {
#else // #ifdef Q_OS_WIN
if (pLibraryTreeItem->child(i)->getName().compare(currentLine) == 0) {
#endif // #ifdef Q_OS_WIN
classExists = true;
break;
}
Expand Down

0 comments on commit 26dbf74

Please sign in to comment.