From f8464228998b4816e6145714712656da142aae82 Mon Sep 17 00:00:00 2001 From: Abhishek-Soni-25 Date: Mon, 2 Jun 2025 18:26:59 +0530 Subject: Prevented crash when removing lint_off option --- src/maker/NgVeri.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/maker/NgVeri.py b/src/maker/NgVeri.py index c5756e7d..1678248f 100755 --- a/src/maker/NgVeri.py +++ b/src/maker/NgVeri.py @@ -338,14 +338,21 @@ class NgVeri(QtWidgets.QWidget): QtWidgets.QMessageBox.Cancel) if ret == QtWidgets.QMessageBox.Ok: - file = open(init_path + "library/tlv/lint_off.txt", 'r') - data = file.readlines() - file.close() - - data.remove(text + "\n") - file = open(init_path + "library/tlv/lint_off.txt", 'w') - for item in data: - file.write(item) + try: + file_path = os.path.join(init_path, "library/tlv/lint_off.txt") + with open(file_path, 'r') as file: + data = file.readlines() + data = [line for line in data if line.strip() != text] + with open(file_path, 'w') as file: + file.writelines(data) + + except Exception as e: + QtWidgets.QMessageBox.warning( + None, + "Warning", + f"Could not remove lint_off entry '{text}'", + QtWidgets.QMessageBox.Ok + ) def add_lint_off(self): ''' -- cgit