From 20cebfd225e6de624bb716ad95ff04862dbf2416 Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Tue, 6 Jan 2026 09:48:33 +0100 Subject: [PATCH] Fix field rename feature Instead of considering the field at position ord, which is somehow buggy, let's consider the already existing old name. Fixes #4487 , also more manual test seems to indicate nothing more is added --- qt/aqt/fields.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/qt/aqt/fields.py b/qt/aqt/fields.py index 16a3b2779..c2918930c 100644 --- a/qt/aqt/fields.py +++ b/qt/aqt/fields.py @@ -130,9 +130,7 @@ class FieldDialog(QDialog): self.saveField() self.loadField(idx) - def _uniqueName( - self, prompt: str, ignoreOrd: int | None = None, old: str = "" - ) -> str | None: + def _uniqueName(self, prompt: str, old: str = "") -> str | None: txt = getOnlyText(prompt, default=old).replace('"', "").strip() if not txt: return None @@ -143,9 +141,9 @@ class FieldDialog(QDialog): if letter in txt: show_warning(tr.fields_name_invalid_letter()) return None + if txt == old: + return None for f in self.model["flds"]: - if ignoreOrd is not None and f["ord"] == ignoreOrd: - continue if f["name"] == txt: show_warning(tr.fields_that_field_name_is_already_used()) return None @@ -157,7 +155,7 @@ class FieldDialog(QDialog): idx = self.currentIdx f = self.model["flds"][idx] - name = self._uniqueName(tr.actions_new_name(), self.currentIdx, f["name"]) + name = self._uniqueName(tr.actions_new_name(), f["name"]) if not name: return