summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2020-12-05 17:25:30 +0200
committerTor Lillqvist <tml@collabora.com>2020-12-05 20:31:07 +0100
commit46601c23ea8cdd772333d19a270ea6c380fc6e94 (patch)
tree548c068f6a0239df04c7df2a3f4b8c861d42ae82 /fpicker
parentcbad3dec6421afb5f0040058bba7b97c3ee09cb4 (diff)
Fix crash or hang on macOS on arm64 when opening a file picker
There is no reason to not mention the NSOpenSavePanelDelegate protocol that AquaFilePickerDelegate implements. The way we used objc_msgSend() caused a crash or hang. (I saw both, depending on whether the code was built for debugging or not). For some reason we used to cast it to a function with variadic parameters like: ((id (*)(id, SEL, ...))objc_msgSend)(m_pDialog, @selector(setDelegate:), m_pDelegate); This does not work in arm64 code on macOS. (See https://developer.apple.com/documentation/apple_silicon/addressing_architectural_differences_in_your_macos_code?language=objc , the "Don't Redeclare a Function to Have Variable Parameters" section.) We could have replaced the ellipsis with the actual type of the first real parameter in this call, or just "id" would have worked fine. But it is much simpler to just do what we mean directly: [m_pDialog setDelegate:m_pDelegate]; I need to look through the code for other places where we have used objc_msgSend() in a similar fashion. Change-Id: Ia93b2007ed8f263eaf99d604a3c88e857efbb421 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107260 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/aqua/AquaFilePickerDelegate.hxx2
-rw-r--r--fpicker/source/aqua/SalAquaFilePicker.mm7
2 files changed, 2 insertions, 7 deletions
diff --git a/fpicker/source/aqua/AquaFilePickerDelegate.hxx b/fpicker/source/aqua/AquaFilePickerDelegate.hxx
index 6ea35ec41d73..100eda11cf71 100644
--- a/fpicker/source/aqua/AquaFilePickerDelegate.hxx
+++ b/fpicker/source/aqua/AquaFilePickerDelegate.hxx
@@ -27,7 +27,7 @@
class SalAquaFilePicker;
class FilterHelper;
-@interface AquaFilePickerDelegate : NSObject
+@interface AquaFilePickerDelegate : NSObject <NSOpenSavePanelDelegate>
{
SalAquaFilePicker* filePicker;
FilterHelper* filterHelper;
diff --git a/fpicker/source/aqua/SalAquaFilePicker.mm b/fpicker/source/aqua/SalAquaFilePicker.mm
index 3ddad83529c4..3fbe8e7c949a 100644
--- a/fpicker/source/aqua/SalAquaFilePicker.mm
+++ b/fpicker/source/aqua/SalAquaFilePicker.mm
@@ -155,12 +155,7 @@ sal_Int16 SAL_CALL SalAquaFilePicker::execute()
//Set the delegate to be notified of certain events
- // I don't know why, but with gcc 4.2.1, this line results in the warning:
- // class 'AquaFilePickerDelegate' does not implement the 'NSOpenSavePanelDelegate' protocol
- // So instead of:
- // [m_pDialog setDelegate:m_pDelegate];
- // do:
- ((id (*)(id, SEL, ...))objc_msgSend)(m_pDialog, @selector(setDelegate:), m_pDelegate);
+ [m_pDialog setDelegate:m_pDelegate];
int nStatus = runandwaitforresult();