Skip to content

Commit 5dbd402

Browse files
authored
Update Screen.swift
Avoid rebinding the memory and instead create a new pointer to the memory at the same location. This avoids triggering an assertion failure in the newer runtimes.
1 parent 267472e commit 5dbd402

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/SwiftWin32/Windows and Screens/Screen.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public final class Screen {
4040
var info: MONITORINFOEXW = MONITORINFOEXW()
4141
info.cbSize = DWORD(MemoryLayout<MONITORINFOEXW>.size)
4242
if (withUnsafeMutablePointer(to: &info) {
43-
$0.withMemoryRebound(to: MONITORINFO.self, capacity: 1) {
44-
GetMonitorInfoW(hMonitor, $0)
45-
}
43+
let pMemoryInfo: UnsafeMutablePointer<MONITORINFO> =
44+
UnsafeMutableRawPointer($0).assumingMemoryBound(to: MONITORINFO.self)
45+
return GetMonitorInfoW(hMonitor, pMemoryInfo)
4646
}) == false { return false }
4747

4848
let szDevice: String = withUnsafePointer(to: &info.szDevice) {

0 commit comments

Comments
 (0)