Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions devel/702.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# [702] 添加针对 QNetworkInterface 的 WASM 条件编译 and 一处语法错误修复

# What
1. 添加了 WASM 平台的条件编译,排除 QNetworkInterface 相关的调用
2. 顺带修复了 qt_stem_device_id 在 WASM 条件编译下的语法错误

# Why
WASM Qt 不支持 QNetworkInterface 相关功能(尽管保留了 include)
7 changes: 7 additions & 0 deletions src/Plugins/Qt/qt_sys_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ qt_get_pretty_os_name () {

bool
qt_has_network_connection () {
#ifdef OS_WASM
// 虽然 QNetworkInterface 可以被 inlcude,但其在 WASM 下不工作
return false;
#else
QList<QNetworkInterface> interfaces= QNetworkInterface::allInterfaces ();
for (int i= 0; i < interfaces.size (); ++i) {
const QNetworkInterface& iface= interfaces.at (i);
Expand All @@ -56,6 +60,7 @@ qt_has_network_connection () {
if (!iface.addressEntries ().isEmpty ()) return true;
}
return false;
#endif
}

#ifdef Q_OS_WINDOWS
Expand Down Expand Up @@ -223,6 +228,8 @@ qt_stem_device_id () {
return from_qstring (get_linux_or_macos_device_id ());
#elif defined(Q_OS_WINDOWS)
return from_qstring (get_windows_device_id ());
#else // OS_WASM
return "";
#endif
}

Expand Down
Loading