diff --git a/src/debugpy/launcher/handlers.py b/src/debugpy/launcher/handlers.py index 479dc02b7..14baac493 100644 --- a/src/debugpy/launcher/handlers.py +++ b/src/debugpy/launcher/handlers.py @@ -49,8 +49,18 @@ def property_or_debug_option(prop_name, flag_name): "--connect", launcher.adapter_host + ":" + str(port), ] + if not request("subProcess", True): cmdline += ["--configure-subProcess", "False"] + + qt_mode = request( + "qt", + json.enum( + "auto", "none", "pyside", "pyside2", "pyqt4", "pyqt5", optional=True + ), + ) + cmdline += ["--configure-qt", qt_mode] + adapter_access_token = request("adapterAccessToken", unicode, optional=True) if adapter_access_token != (): cmdline += ["--adapter-access-token", compat.filename(adapter_access_token)] diff --git a/src/debugpy/server/api.py b/src/debugpy/server/api.py index 3615d5234..65794c7c1 100644 --- a/src/debugpy/server/api.py +++ b/src/debugpy/server/api.py @@ -22,7 +22,16 @@ _tls = threading.local() # TODO: "gevent", if possible. -_config = {"subProcess": True} +_config = { + "qt": "auto", + "subProcess": True, +} + +_config_valid_values = { + # If property is not listed here, any value is considered valid, so long as + # its type matches that of the default value in _config. + "qt": ["auto", "none", "pyside", "pyside2", "pyqt4", "pyqt5"], +} # This must be a global to prevent it from being garbage collected and triggering # https://bugs.python.org/issue37380. @@ -85,6 +94,9 @@ def configure(properties, **kwargs): expected_type = type(_config[k]) if type(v) is not expected_type: raise ValueError(fmt("{0!r} must be a {1}", k, expected_type.__name__)) + valid_values = _config_valid_values.get(k) + if (valid_values is not None) and (v not in valid_values): + raise ValueError(fmt("{0!r} must be one of: {1!r}", k, valid_values)) _config[k] = v @@ -109,6 +121,10 @@ def debug(address, **kwargs): log.debug("{0}({1!r}, **{2!r})", func.__name__, address, kwargs) log.info("Initial debug configuration: {0!j}", _config) + qt_mode = _config.get("qt", "auto") + if qt_mode != "none": + pydevd.enable_qt_support(qt_mode) + settrace_kwargs = { "suspend": False, "patch_multiprocessing": _config.get("subProcess", True), diff --git a/src/debugpy/server/cli.py b/src/debugpy/server/cli.py index 5014f0047..d411b066b 100644 --- a/src/debugpy/server/cli.py +++ b/src/debugpy/server/cli.py @@ -50,7 +50,7 @@ class Options(object): options = Options() -options.config = {"subProcess": True} +options.config = {"qt": "auto", "subProcess": True} def in_range(parser, start, stop):