diff options
| author | Cecilio Pardo | 2024-11-14 09:55:56 +0100 |
|---|---|---|
| committer | Eli Zaretskii | 2024-11-14 18:05:11 +0200 |
| commit | b83a45eab53b8e6d8f3be45c0acb9a42a5262cb0 (patch) | |
| tree | 6128157c5892cfff66046ecf7caeb2c2ce35d0b0 /src | |
| parent | 70273dc9f7e01e5330abedb44b1c3e46430fbc69 (diff) | |
| download | emacs-b83a45eab53b8e6d8f3be45c0acb9a42a5262cb0.tar.gz emacs-b83a45eab53b8e6d8f3be45c0acb9a42a5262cb0.zip | |
Fix drag-n-drop on MS-Windows
* src/w32fns.c (struct w32_drop_target): New member 'ref_count'.
(w32_drop_target_AddRef): Increment reference count.
(w32_drop_target_Release): Decrement reference count, and free the
target only if the reference count is zero.
(w32_createwindow): Initialize reference count. (Bug#74312)
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32fns.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index 1bd3d5099e2..e2455b9271e 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -2562,6 +2562,7 @@ struct w32_drop_target { | |||
| 2562 | /* i_drop_target must be the first member. */ | 2562 | /* i_drop_target must be the first member. */ |
| 2563 | IDropTarget i_drop_target; | 2563 | IDropTarget i_drop_target; |
| 2564 | HWND hwnd; | 2564 | HWND hwnd; |
| 2565 | int ref_count; | ||
| 2565 | }; | 2566 | }; |
| 2566 | 2567 | ||
| 2567 | static HRESULT STDMETHODCALLTYPE | 2568 | static HRESULT STDMETHODCALLTYPE |
| @@ -2573,13 +2574,16 @@ w32_drop_target_QueryInterface (IDropTarget *t, REFIID ri, void **r) | |||
| 2573 | static ULONG STDMETHODCALLTYPE | 2574 | static ULONG STDMETHODCALLTYPE |
| 2574 | w32_drop_target_AddRef (IDropTarget *This) | 2575 | w32_drop_target_AddRef (IDropTarget *This) |
| 2575 | { | 2576 | { |
| 2576 | return 1; | 2577 | struct w32_drop_target *target = (struct w32_drop_target *) This; |
| 2578 | return ++target->ref_count; | ||
| 2577 | } | 2579 | } |
| 2578 | 2580 | ||
| 2579 | static ULONG STDMETHODCALLTYPE | 2581 | static ULONG STDMETHODCALLTYPE |
| 2580 | w32_drop_target_Release (IDropTarget *This) | 2582 | w32_drop_target_Release (IDropTarget *This) |
| 2581 | { | 2583 | { |
| 2582 | struct w32_drop_target *target = (struct w32_drop_target *) This; | 2584 | struct w32_drop_target *target = (struct w32_drop_target *) This; |
| 2585 | if (--target->ref_count > 0) | ||
| 2586 | return target->ref_count; | ||
| 2583 | free (target->i_drop_target.lpVtbl); | 2587 | free (target->i_drop_target.lpVtbl); |
| 2584 | free (target); | 2588 | free (target); |
| 2585 | return 0; | 2589 | return 0; |
| @@ -2770,6 +2774,7 @@ w32_createwindow (struct frame *f, int *coords) | |||
| 2770 | if (vtbl != NULL) | 2774 | if (vtbl != NULL) |
| 2771 | { | 2775 | { |
| 2772 | drop_target->hwnd = hwnd; | 2776 | drop_target->hwnd = hwnd; |
| 2777 | drop_target->ref_count = 0; | ||
| 2773 | drop_target->i_drop_target.lpVtbl = vtbl; | 2778 | drop_target->i_drop_target.lpVtbl = vtbl; |
| 2774 | vtbl->QueryInterface = w32_drop_target_QueryInterface; | 2779 | vtbl->QueryInterface = w32_drop_target_QueryInterface; |
| 2775 | vtbl->AddRef = w32_drop_target_AddRef; | 2780 | vtbl->AddRef = w32_drop_target_AddRef; |