#include "asynchelper.h" #include AsyncHelper *AsyncHelper::m_instance = nullptr; AsyncHelper *AsyncHelper::instance() { if (!m_instance) { m_instance = new AsyncHelper(); } return m_instance; } AsyncHelper::AsyncHelper(QObject *parent) : QObject(parent) {} // 修改安全执行回调的辅助函数实现 void safeExecuteCallback(const std::function &callback, const QString &callbackType) { if (!callback) { qDebug() << "回调函数为空,跳过执行" << callbackType; return; } try { callback(); } catch (const std::exception &e) { qWarning() << "执行" << callbackType << "回调时发生异常:" << e.what(); } catch (...) { qWarning() << "执行" << callbackType << "回调时发生未知异常"; } }