unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Cecilio Pardo <cpardo@imayhem.com>
To: Kazuhiro Ito <kzhr@d1.dion.ne.jp>,
	74312@debbugs.gnu.org, Eli Zaretskii <eliz@gnu.org>
Subject: bug#74312: 31.0.50; Cygw32 build break
Date: Thu, 14 Nov 2024 09:55:56 +0100	[thread overview]
Message-ID: <d9c00a8f-67bc-44bc-a74f-44a1de4c0cf2@imayhem.com> (raw)
In-Reply-To: <85msi3jfh6.wl--xmue@d1.dion.ne.jp>

On 13/11/2024 16:55, Kazuhiro Ito wrote:
>>> Both Emacsen may fail to handle dropped files if I do drag-n-drop
>>> files very quickly.  I confirmed Microsoft Photo application on
>>> Windows 11.  And, once Emacs failed to handle drop event, it keeps
>>> ignoring dropping files or text event.
>>
>> I will look into this.
> 
> As far as I tested, drag-n-drop from Microsoft Photo worked only the
> first time.  Second operation was ignored.  Quick operation may fail
> even at the first time.  Drag-n-drop from explorer worked expectedly.

This should fix the Photo application problem.

I didn't expect ref counting to be needed for this, my bad.

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 @@ w32_process_dnd_data (int format, void *hGlobal)
    /* i_drop_target must be the first member.  */
    IDropTarget i_drop_target;
    HWND hwnd;
+  int ref_count;
  };

  static HRESULT STDMETHODCALLTYPE
@@ -2573,13 +2574,16 @@ w32_drop_target_QueryInterface (IDropTarget *t, 
REFIID ri, void **r)
  static ULONG STDMETHODCALLTYPE
  w32_drop_target_AddRef (IDropTarget *This)
  {
-  return 1;
+  struct w32_drop_target *target = (struct w32_drop_target *) This;
+  return ++target->ref_count;
  }

  static ULONG STDMETHODCALLTYPE
  w32_drop_target_Release (IDropTarget *This)
  {
    struct w32_drop_target *target = (struct w32_drop_target *) This;
+  if (--target->ref_count > 0)
+    return target->ref_count;
    free (target->i_drop_target.lpVtbl);
    free (target);
    return 0;
@@ -2770,6 +2774,7 @@ w32_createwindow (struct frame *f, int *coords)
  	  if (vtbl != NULL)
  	    {
  	      drop_target->hwnd = hwnd;
+	      drop_target->ref_count = 0;
  	      drop_target->i_drop_target.lpVtbl = vtbl;
  	      vtbl->QueryInterface = w32_drop_target_QueryInterface;
  	      vtbl->AddRef = w32_drop_target_AddRef;








  reply	other threads:[~2024-11-14  8:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 14:51 bug#74312: 31.0.50; Cygw32 build break Kazuhiro Ito
2024-11-11 16:07 ` Eli Zaretskii
2024-11-11 18:08   ` Ken Brown
2024-11-11 20:13     ` Eli Zaretskii
2024-11-11 22:50       ` Ken Brown
2024-11-12 12:42         ` Eli Zaretskii
2024-11-12 16:14           ` Kazuhiro Ito
2024-11-12 16:47             ` Eli Zaretskii
2024-11-13 10:59               ` Kazuhiro Ito
2024-11-13 12:33                 ` Cecilio Pardo
2024-11-13 15:55                   ` Kazuhiro Ito
2024-11-14  8:55                     ` Cecilio Pardo [this message]
2024-11-14  9:39                       ` Eli Zaretskii
2024-11-14 10:05                         ` Cecilio Pardo
2024-11-14 15:00                       ` Kazuhiro Ito
2024-11-14 16:07                         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d9c00a8f-67bc-44bc-a74f-44a1de4c0cf2@imayhem.com \
    --to=cpardo@imayhem.com \
    --cc=74312@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=kzhr@d1.dion.ne.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).