aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCecilio Pardo2024-11-14 09:55:56 +0100
committerEli Zaretskii2024-11-14 18:05:11 +0200
commitb83a45eab53b8e6d8f3be45c0acb9a42a5262cb0 (patch)
tree6128157c5892cfff66046ecf7caeb2c2ce35d0b0 /src
parent70273dc9f7e01e5330abedb44b1c3e46430fbc69 (diff)
downloademacs-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.c7
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
2567static HRESULT STDMETHODCALLTYPE 2568static HRESULT STDMETHODCALLTYPE
@@ -2573,13 +2574,16 @@ w32_drop_target_QueryInterface (IDropTarget *t, REFIID ri, void **r)
2573static ULONG STDMETHODCALLTYPE 2574static ULONG STDMETHODCALLTYPE
2574w32_drop_target_AddRef (IDropTarget *This) 2575w32_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
2579static ULONG STDMETHODCALLTYPE 2581static ULONG STDMETHODCALLTYPE
2580w32_drop_target_Release (IDropTarget *This) 2582w32_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;