Currently if VO init fails, the context menu is leaked. Additionally, init/uninit are in the VO thread, while other accesses are in the GUI thread. Fix this by moving them to the GUI thread, similar to other resources. This also lets init function take the mpv HWND in the next commit.
Unified · Split
| @@ -2031,6 +2031,7 @@ static MP_THREAD_VOID gui_thread(void *ptr) · 2030 unmodified lines | |||
| 2031 | goto done; | 2031 | goto done; |
| 2032 | } | 2032 | } |
| 2033 | 2033 | ||
| 2034 | w32->menu_ctx = mp_win32_menu_init(); | ||
| 2034 | update_dark_mode(w32); | 2035 | update_dark_mode(w32); |
| 2035 | update_corners_pref(w32); | 2036 | update_corners_pref(w32); |
| 2036 | if (w32->opts->window_affinity) | 2037 | if (w32->opts->window_affinity) |
| @@ -2106,6 +2107,8 @@ done: · 69 unmodified lines | |||
| 2106 | MP_VERBOSE(w32, "uninit\n"); | 2107 | MP_VERBOSE(w32, "uninit\n"); |
| 2107 | 2108 | ||
| 2108 | remove_parent_hook(w32); | 2109 | remove_parent_hook(w32); |
| 2110 | if (w32->menu_ctx) | ||
| 2111 | mp_win32_menu_uninit(w32->menu_ctx); | ||
| 2109 | if (w32->window && !w32->destroyed) | 2112 | if (w32->window && !w32->destroyed) |
| 2110 | DestroyWindow(w32->window); | 2113 | DestroyWindow(w32->window); |
| 2111 | if (w32->taskbar_list) | 2114 | if (w32->taskbar_list) |
| @@ -2131,7 +2134,6 @@ bool vo_w32_init(struct vo *vo) · 19 unmodified lines | |||
| 2131 | .dispatch = mp_dispatch_create(w32), | 2134 | .dispatch = mp_dispatch_create(w32), |
| 2132 | }; | 2135 | }; |
| 2133 | w32->opts = w32->opts_cache->opts; | 2136 | w32->opts = w32->opts_cache->opts; |
| 2134 | w32->menu_ctx = mp_win32_menu_init(); | ||
| 2135 | vo->w32 = w32; | 2137 | vo->w32 = w32; |
| 2136 | 2138 | ||
| 2137 | if (mp_thread_create(&w32->thread, gui_thread, w32)) | 2139 | if (mp_thread_create(&w32->thread, gui_thread, w32)) |
| @@ -2422,7 +2424,6 @@ void vo_w32_uninit(struct vo *vo) · 284 unmodified lines | |||
| 2422 | 2424 | ||
| 2423 | AvRevertMmThreadCharacteristics(w32->avrt_handle); | 2425 | AvRevertMmThreadCharacteristics(w32->avrt_handle); |
| 2424 | 2426 | ||
| 2425 | mp_win32_menu_uninit(w32->menu_ctx); | ||
| 2426 | talloc_free(w32); | 2427 | talloc_free(w32); |
| 2427 | vo->w32 = NULL; | 2428 | vo->w32 = NULL; |
| 2428 | } | 2429 | } |