重新修改代码,尽可能缩小影响范围

This commit is contained in:
lyousan 2024-07-23 02:19:16 +08:00
parent 563f077964
commit bb92657901

View File

@ -22,6 +22,7 @@ from .._functions.settings import Settings
from .._functions.tools import PortFinder
from .._functions.tools import raise_error
from .._pages.chromium_base import Timeout
from .._pages.chromium_frame import ChromiumFrame
from .._pages.tabs import ChromiumTab, MixTab
from .._units.downloader import DownloadManager
from .._units.setter import BrowserSetter
@ -457,10 +458,18 @@ class Chromium(object):
:param owner: 使用该驱动的对象
:return: Driver对象
"""
d = self._drivers.get(tab_id, None)
if isinstance(owner, ChromiumFrame):
d = self._drivers.get(tab_id, None)
if not d:
d = Driver(tab_id, 'page', self.address)
d.owner = owner
self._drivers[tab_id] = d
self._all_drivers.setdefault(tab_id, set()).add(d)
return d
d = self._drivers.pop(tab_id, None)
if not d:
d = Driver(tab_id, 'page', self.address)
self._drivers[tab_id] = d
d.owner = owner
self._all_drivers.setdefault(tab_id, set()).add(d)
return d