Skip to content

Commit

Permalink
Fix Traceback when adding empty tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Koski committed Jan 15, 2024
1 parent 67d9b49 commit 921f400
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions spinetoolbox/spine_db_editor/widgets/multi_spine_db_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,23 @@ def _make_new_tab(self, db_url_codenames=None, window=False): # pylint: disable
if not tab.load_db_urls(db_url_codenames, create=True, window=window):
return
# Checks if the same url is already opened under a different codename
for url, codename in db_url_codenames.items():
current_codename = codename
for db_map in self.db_mngr.db_maps:
is_same = str(url) == db_map.db_url
is_same = is_same and codename != db_map.codename
if is_same:
existing = db_map.codename
msg = QMessageBox(self.parent())
msg.setIcon(QMessageBox.Icon.Information)
msg.setWindowTitle(current_codename)
msg.setText(
f"<p>The same database is already open in another window. Opening the new window under "
f"the same name as the existing one: <b>{existing}</b></p>"
)
msg.exec()
break
if db_url_codenames:
for url, codename in db_url_codenames.items():
current_codename = codename
for db_map in self.db_mngr.db_maps:
is_same = str(url) == db_map.db_url
is_same = is_same and codename != db_map.codename
if is_same:
existing = db_map.codename
msg = QMessageBox(self.parent())
msg.setIcon(QMessageBox.Icon.Information)
msg.setWindowTitle(current_codename)
msg.setText(
f"<p>The same database is already open in another window. Opening the new window under "
f"the same name as the existing one: <b>{existing}</b></p>"
)
msg.exec()
break
return tab

def show_plus_button_context_menu(self, global_pos):
Expand Down

0 comments on commit 921f400

Please sign in to comment.