unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Third <alan@idiocy.org>
To: Andrii Kolomoiets <andreyk.mad@gmail.com>
Cc: 43973@debbugs.gnu.org
Subject: bug#43973: 28.0.50; [NS] Two crashes on macOS
Date: Sat, 2 Jan 2021 18:25:36 +0000	[thread overview]
Message-ID: <X/C6oAfP3eOdTt0j@breton.holly.idiocy.org> (raw)
In-Reply-To: <m2ft6gwkzr.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 763 bytes --]

On Thu, Oct 15, 2020 at 12:33:44AM +0300, Andrii Kolomoiets wrote:
> Alan Third <alan@idiocy.org> writes:
> 
> >> The frame must be small enough to not all the toolbar buttons fits the
> >> toolbar:
> >> 
> >> (setq test-frame (make-frame `((parent-frame . ,(selected-frame))
> >> 			                   (width . 41))))
> >> 
> >> The last button (isearch) is replaced by ">>".
> >
> > Funnily enough that ">>" is what I was looking at. I guess it's a
> > toolkit image and not something we provide with Emacs...?
> >
> >> There are no crash if '(width . 42)'.
> >
> > Can you try this:

Can you please try the attached patch. It looks like NSToolbarItem
makes a copy of the image, but EmacsImage is not set up to create
copies of itself correctly.
-- 
Alan Third

[-- Attachment #2: 0001-Fix-crash-in-NS-toolbar-image-releasing-bug-43973.patch --]
[-- Type: text/plain, Size: 1195 bytes --]

From d111484d44744e3f68775a47b7f15ddf0d9b38c0 Mon Sep 17 00:00:00 2001
From: Alan Third <alan@idiocy.org>
Date: Sat, 2 Jan 2021 18:19:39 +0000
Subject: [PATCH] Fix crash in NS toolbar image releasing (bug#43973)

The toolbar fails to make a proper copy of EmacsImage objects, so
releasing the copy incorrectly released instance variables from the
original objects.

* src/nsimage.m ([EmacsImage copyWithZone:]): New function to enable
correct copying of EmacsImage.
---
 src/nsimage.m | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/nsimage.m b/src/nsimage.m
index f0014b50b9..fa81a41a51 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -293,6 +293,18 @@ - (void)dealloc
 }
 
 
+- (id)copyWithZone:(NSZone *)zone
+{
+  EmacsImage *copy = [super copyWithZone:zone];
+
+  copy->stippleMask = [stippleMask copyWithZone:zone];
+  copy->bmRep = [bmRep copyWithZone:zone];
+  copy->transform = [transform copyWithZone:zone];
+
+  return copy;
+}
+
+
 /* Create image from monochrome bitmap. If both FG and BG are 0
    (black), set the background to white and make it transparent.  */
 - (instancetype)initFromXBM: (unsigned char *)bits width: (int)w height: (int)h
-- 
2.29.2


  reply	other threads:[~2021-01-02 18:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13  7:35 bug#43973: 28.0.50; [NS] Two crashes on macOS Andrii Kolomoiets
2020-10-13 13:00 ` Robert Pluim
2020-10-13 20:33   ` Alan Third
2020-10-14 10:46     ` Robert Pluim
2020-10-13 19:09 ` Alan Third
2020-10-14  8:07   ` Andrii Kolomoiets
2020-10-14  8:50   ` Andrii Kolomoiets
2020-10-24 10:35   ` Eli Zaretskii
2020-10-14 20:41 ` Alan Third
2020-10-14 21:01   ` Andrii Kolomoiets
2020-10-14 21:15     ` Alan Third
2020-10-14 21:33       ` Andrii Kolomoiets
2021-01-02 18:25         ` Alan Third [this message]
2021-01-02 22:03           ` Andrii Kolomoiets
2021-01-02 22:34             ` Alan Third
2020-10-24  1:37 ` Win Treese
2020-10-24 16:59   ` Alan Third

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=X/C6oAfP3eOdTt0j@breton.holly.idiocy.org \
    --to=alan@idiocy.org \
    --cc=43973@debbugs.gnu.org \
    --cc=andreyk.mad@gmail.com \
    /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).