Skip to content

配置文件非法,导致找不到设备/app/游戏时,日志比较难读 #28

@blacksea3

Description

@blacksea3

现象:配置文件非法,导致找不到设备/app/游戏时,日志比较难读

代码位置:
此文件ok/gui/StartController.py
类StartController
方法check_device_error(self):
以下代码段

        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为空的判断

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions