From fec3640cbe216bd87e92632a726ad44a88743553 Mon Sep 17 00:00:00 2001 From: Massimo Capodiferro <77293250+maxcapodi78@users.noreply.github.com> Date: Thu, 30 May 2024 18:09:08 +0200 Subject: [PATCH] FIX: bug on multidesktop in case of connection to existing sessions. (#4743) Co-authored-by: maxcapodi78 --- pyaedt/desktop.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyaedt/desktop.py b/pyaedt/desktop.py index e113168aa5c..dcaa6a370d6 100644 --- a/pyaedt/desktop.py +++ b/pyaedt/desktop.py @@ -429,20 +429,23 @@ class Desktop(object): def __new__(cls, *args, **kwargs): # The following commented lines will be useful when we will need to search among multiple saved desktop. - # specified_version = kwargs.get("specified_version") or None if not args else args[0] + specified_version = kwargs.get("specified_version") or None if (not args or len(args) < 1) else args[0] new_desktop_session = kwargs.get("new_desktop_session") or False if (not args or len(args) < 3) else args[2] # student_version = kwargs.get("student_version") or False if (not args or len(args)<5) else args[4] # machine = kwargs.get("machine") or "" if (not args or len(args)<6) else args[5] + specified_version = get_string_version(specified_version) port = kwargs.get("port") or 0 if (not args or len(args) < 7) else args[6] aedt_process_id = kwargs.get("aedt_process_id") or None if (not args or len(args) < 8) else args[7] if settings.use_multi_desktop and not inside_desktop and new_desktop_session: pyaedt_logger.info("Initializing new Desktop session.") return object.__new__(cls) elif len(_desktop_sessions.keys()) > 0: - if settings.use_multi_desktop and (port or aedt_process_id): + if settings.use_multi_desktop and (port or aedt_process_id or specified_version): for el in list(_desktop_sessions.values()): - if (el.port != 0 and el.port == port) or ( - el.aedt_process_id and el.aedt_process_id == aedt_process_id + if ( + (port != 0 and el.port == port) + or (aedt_process_id and el.aedt_process_id == aedt_process_id) + or (not port and not aedt_process_id and el.aedt_version_id == specified_version) ): return el return object.__new__(cls)