fix crash when an output goes away

happens e.g. when a monitor is powered off.
The wl_output interface published by dwl has version 1, but the
wl_output_release request is only supported since version 3.
This commit is contained in:
Raphael Robatsch 2022-12-03 18:30:32 +01:00
parent c076d343fc
commit 83f59945a6
1 changed files with 7 additions and 1 deletions

View File

@ -54,8 +54,14 @@ struct WlDeleter;
template<typename T> template<typename T>
using wl_unique_ptr = std::unique_ptr<T, WlDeleter<T>>; using wl_unique_ptr = std::unique_ptr<T, WlDeleter<T>>;
inline void wl_output_release_checked(wl_output* output) {
if (wl_output_get_version(output) >= WL_OUTPUT_RELEASE_SINCE_VERSION) {
wl_output_release(output);
}
}
WL_DELETER(wl_buffer, wl_buffer_destroy); WL_DELETER(wl_buffer, wl_buffer_destroy);
WL_DELETER(wl_output, wl_output_release); WL_DELETER(wl_output, wl_output_release_checked);
WL_DELETER(wl_pointer, wl_pointer_release); WL_DELETER(wl_pointer, wl_pointer_release);
WL_DELETER(wl_seat, wl_seat_release); WL_DELETER(wl_seat, wl_seat_release);
WL_DELETER(wl_surface, wl_surface_destroy); WL_DELETER(wl_surface, wl_surface_destroy);