i was writing my own wrapper and wondering how others solved wrapping monitors safely and i guess the answer is they simply dont...
there are several issues with just this screenshot where undefined behavior leaks into safe rust:
glfwGetWindowMonitor() might return null. this is not checked
glfwGetMonitorPos() it is not legal to supply null for the monitor paramter here (but might be given the function above)
and even further that monitor even saves a monitor pointer is illegal since glfw*Events() might invalidate those pointers making them point to trash memory. (after a monitor is disconnected)
and even further still there is no checking for the validity of the thread the monitor is created in. glfw is not thread safe for the most part and a monitor created on anything but the thread glfwInit() is called on is undefined behavior.
this is why i dont use any crates from crates.io. the state of rust is abysmal...
i was writing my own wrapper and wondering how others solved wrapping monitors safely and i guess the answer is they simply dont...
there are several issues with just this screenshot where undefined behavior leaks into safe rust:
glfwGetWindowMonitor()
might return null. this is not checkedglfwGetMonitorPos()
it is not legal to supply null for the monitor paramter here (but might be given the function above)and even further that monitor even saves a monitor pointer is illegal since
glfw*Events()
might invalidate those pointers making them point to trash memory. (after a monitor is disconnected)and even further still there is no checking for the validity of the thread the monitor is created in. glfw is not thread safe for the most part and a monitor created on anything but the thread
glfwInit()
is called on is undefined behavior.this is why i dont use any crates from crates.io. the state of rust is abysmal...