You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
try:
device = og.device_manager.get_preferred_device()
error_msg = self.tr("{} is not connected, please select the game window.").format(
device['nick']) # device为空时 此处异常
logger.debug(f'test check_device_error msg: {error_msg}')
if not device:
return self.tr('No game selected!') # device为空时 此分支走不到
在device为空时,device['nick'] 会抛异常 TypeError: 'NoneType' object is not subscriptable。 永远无法走到if not device分支内。 影响看日志。
建议:
if not device的分支往前面提取;或者device['nick']带一个device为空的判断
Activity
[-]调试源码时的部分分支逻辑优化建议[/-][+]配置文件非法,导致找不到设备/app/游戏时,日志比较难读[/+]