Skip to content

退出应用后出现 QThreadStorage 警告 #1

@KeqingMoe

Description

@KeqingMoe

问题描述

example/counter 在正常退出、关闭窗口后,控制台会打印类似下面的警告:

QThreadStorage: entry 0 destroyed before end of thread 0x3948e010090

该问题从项目一开始(从 moonbridge 迁移过来时)就存在,不是最近改动引入的回归。

复现方式

在 macOS 环境下运行示例:

moon run src/example/counter

打开窗口后直接关闭,即可在控制台看到上述警告。

当前观察

目前项目中的 Qt 对象统一通过 QSharedPointer 包装后再暴露给 MoonBit。

初步怀疑这个警告与 Qt 对象,尤其是 QApplication / QObject 相关对象的析构时机过晚有关:它们可能一直存活到 MoonBit 运行时或进程退出阶段才被清理,导致 Qt 的线程局部存储析构顺序不理想,从而打印该警告。

备注

这是一个已知问题,暂时不阻塞当前功能开发。等后续重新审视 Qt 与 MoonBit 互操作的对象和所有权模型时一并处理。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions