Skip to content

Commit

Permalink
chore: 一些小优化
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Jan 26, 2024
1 parent 45b8b3d commit 2a3c74d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
6 changes: 5 additions & 1 deletion source/MaaToolkit/API/MaaToolkitDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ MaaSize MaaToolkitWaitForFindDeviceToComplete()

MaaSize MaaToolkitGetDeviceCount()
{
return device_mgr.get_devices().value_or(std::vector<Device> {}).size();
auto devices = device_mgr.get_devices();
if (!devices) {
return 0;
}
return devices->size();
}

MaaStringView MaaToolkitGetDeviceName(MaaSize index)
Expand Down
1 change: 0 additions & 1 deletion source/MaaToolkit/AdbDevice/DeviceMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ bool DeviceMgr::is_find_completed() const
}

if (!find_device_future_.valid()) {
LogError << "find_device_future_ is not running";
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions source/MaaUtils/IOStream/ChildPipeIOStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ struct prevent_inherit : boost::process::extend::handler
template <typename Char, typename Sequence>
void on_setup(boost::process::extend::windows_executor<Char, Sequence>& exec)
{
SIZE_T size;
SIZE_T size = 0;
InitializeProcThreadAttributeList(NULL, 1, 0, &size);
auto attrlist = reinterpret_cast<LPPROC_THREAD_ATTRIBUTE_LIST>(HeapAlloc(GetProcessHeap(), 0, size));
InitializeProcThreadAttributeList(attrlist, 1, 0, &size);
HANDLE empty[1];
HANDLE empty[1] = {};
UpdateProcThreadAttribute(attrlist, 0, PROC_THREAD_ATTRIBUTE_HANDLE_LIST, empty, 0, NULL, NULL);
exec.startup_info_ex.lpAttributeList = attrlist;
}
Expand Down

0 comments on commit 2a3c74d

Please sign in to comment.