[Libreoffice-commits] core.git: Branch 'private/tml/lov-7.0.3.3' - 2 commits - extensions/source fpicker/source sfx2/source
Tor Lillqvist (via logerrit)
logerrit at kemper.freedesktop.org
Sat Dec 5 20:42:56 UTC 2020
extensions/source/macosx/spotlight/OOoContentDataParser.h | 2 -
extensions/source/macosx/spotlight/OOoContentDataParser.m | 7 -----
extensions/source/macosx/spotlight/OOoMetaDataParser.h | 2 -
extensions/source/macosx/spotlight/OOoMetaDataParser.m | 6 ----
fpicker/source/aqua/AquaFilePickerDelegate.hxx | 2 -
fpicker/source/aqua/SalAquaFilePicker.mm | 8 ------
sfx2/source/appl/shutdowniconaqua.mm | 18 ++------------
7 files changed, 9 insertions(+), 36 deletions(-)
New commits:
commit 861f0064911763540b75cc04f730e3287d04cd6c
Author: Tor Lillqvist <tml at iki.fi>
AuthorDate: Sat Dec 5 18:16:37 2020 +0200
Commit: Tor Lillqvist <tml at iki.fi>
CommitDate: Sat Dec 5 22:04:50 2020 +0200
Remove remaining bogus use of objc_msgSend()
Follow-up to 5bf61e98b0746a4afeb68a80e54b4eb4bf4ea89f.
Should avoid crashes when running as arm64 code on macOS on arm64.
Change-Id: Id05d182684df82c8a7bf09f6bb7e8ccb01997b62
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107259
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml at collabora.com>
diff --git a/extensions/source/macosx/spotlight/OOoContentDataParser.h b/extensions/source/macosx/spotlight/OOoContentDataParser.h
index 7112497cf7de..dc07a3166122 100644
--- a/extensions/source/macosx/spotlight/OOoContentDataParser.h
+++ b/extensions/source/macosx/spotlight/OOoContentDataParser.h
@@ -19,7 +19,7 @@
#import <Cocoa/Cocoa.h>
- at interface OOoContentDataParser : NSObject {
+ at interface OOoContentDataParser : NSObject <NSXMLParserDelegate> {
// indicates if we are interested in an element's content
BOOL shouldReadCharacters;
diff --git a/extensions/source/macosx/spotlight/OOoContentDataParser.m b/extensions/source/macosx/spotlight/OOoContentDataParser.m
index d3ecf16ffaab..e1f51e5b90c7 100644
--- a/extensions/source/macosx/spotlight/OOoContentDataParser.m
+++ b/extensions/source/macosx/spotlight/OOoContentDataParser.m
@@ -47,12 +47,7 @@
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
- // Once again...
- // class 'OOoContentDataParser' does not implement the 'NSXMLParserDelegate' protocol
- // So instead of this:
- // [parser setDelegate:self];
- // do this:
- ((id (*)(id, SEL, ...))objc_msgSend)(parser, @selector(setDelegate:), self);
+ [parser setDelegate:self];
[parser setShouldResolveExternalEntities:NO];
[parser parse];
diff --git a/extensions/source/macosx/spotlight/OOoMetaDataParser.h b/extensions/source/macosx/spotlight/OOoMetaDataParser.h
index 5db7634cce0c..85d48b1735d7 100644
--- a/extensions/source/macosx/spotlight/OOoMetaDataParser.h
+++ b/extensions/source/macosx/spotlight/OOoMetaDataParser.h
@@ -20,7 +20,7 @@
#import <Cocoa/Cocoa.h>
- at interface OOoMetaDataParser : NSObject {
+ at interface OOoMetaDataParser : NSObject <NSXMLParserDelegate> {
//indicates if content should be read
BOOL shouldReadCharacters;
//indicates if the current element is a custom metadata tag
diff --git a/extensions/source/macosx/spotlight/OOoMetaDataParser.m b/extensions/source/macosx/spotlight/OOoMetaDataParser.m
index 2b4dac82c555..1e7cac685b88 100644
--- a/extensions/source/macosx/spotlight/OOoMetaDataParser.m
+++ b/extensions/source/macosx/spotlight/OOoMetaDataParser.m
@@ -91,11 +91,7 @@ static NSDictionary *metaXML2MDIKeys;
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data];
- // class 'OOoMetaDataParser' does not implement the 'NSXMLParserDelegate' protocol
- // So instead of this:
- // [parser setDelegate:self];
- // do this:
- ((id (*)(id, SEL, ...))objc_msgSend)(parser, @selector(setDelegate:), self);
+ [parser setDelegate:self];
[parser setShouldResolveExternalEntities:NO];
[parser parse];
diff --git a/sfx2/source/appl/shutdowniconaqua.mm b/sfx2/source/appl/shutdowniconaqua.mm
index 78c89f33865c..14e4046a4de9 100644
--- a/sfx2/source/appl/shutdowniconaqua.mm
+++ b/sfx2/source/appl/shutdowniconaqua.mm
@@ -146,7 +146,7 @@ class RecentFilesStringLength : public ::cppu::WeakImplHelper< css::util::XStrin
}
- at interface RecentMenuDelegate : NSObject
+ at interface RecentMenuDelegate : NSObject <NSMenuDelegate>
{
std::vector< RecentMenuEntry >* m_pRecentFilesItems;
}
@@ -347,16 +347,7 @@ static void appendRecentMenu( NSMenu* i_pMenu, NSMenu* i_pDockMenu, const OUStri
[pItem setEnabled: YES];
NSMenu* pRecentMenu = [[NSMenu alloc] initWithTitle: getAutoreleasedString( i_rTitle ) ];
- // When compiling against 10.6 SDK, we get the warning:
- // class 'RecentMenuDelegate' does not implement the 'NSMenuDelegate' protocol
-
- // No idea if that is a bogus warning, or if the way this is
- // implemented just is so weird that the compiler gets
- // confused. Anyway, to avoid warnings, instead of this:
- // [pRecentMenu setDelegate: pRecentDelegate];
- // do this:
- reinterpret_cast<id (*)(id, SEL, ...)>(objc_msgSend)(
- pRecentMenu, @selector(setDelegate:), pRecentDelegate);
+ [pRecentMenu setDelegate: pRecentDelegate];
[pRecentMenu setAutoenablesItems: NO];
[pItem setSubmenu: pRecentMenu];
@@ -371,10 +362,7 @@ static void appendRecentMenu( NSMenu* i_pMenu, NSMenu* i_pDockMenu, const OUStri
[pItem setEnabled: YES];
pRecentMenu = [[NSMenu alloc] initWithTitle: getAutoreleasedString( i_rTitle ) ];
- // See above
- // [pRecentMenu setDelegate: pRecentDelegate];
- reinterpret_cast<id (*)(id, SEL, ...)>(objc_msgSend)(
- pRecentMenu, @selector(setDelegate:), pRecentDelegate);
+ [pRecentMenu setDelegate: pRecentDelegate];
[pRecentMenu setAutoenablesItems: NO];
[pItem setSubmenu: pRecentMenu];
commit 222dcd23a8a065d8bbb69aa12c84e9883fdfa472
Author: Tor Lillqvist <tml at iki.fi>
AuthorDate: Sat Dec 5 17:25:30 2020 +0200
Commit: Tor Lillqvist <tml at iki.fi>
CommitDate: Sat Dec 5 22:04:42 2020 +0200
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:
reinterpret_cast<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/+/107257
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml at collabora.com>
diff --git a/fpicker/source/aqua/AquaFilePickerDelegate.hxx b/fpicker/source/aqua/AquaFilePickerDelegate.hxx
index eb7e1ce402e6..fb158cd67633 100644
--- a/fpicker/source/aqua/AquaFilePickerDelegate.hxx
+++ b/fpicker/source/aqua/AquaFilePickerDelegate.hxx
@@ -27,7 +27,7 @@
class SalAquaFilePicker;
class FilterHelper;
- at interface AquaFilePickerDelegate : NSObject
+ at interface AquaFilePickerDelegate : NSObject <NSOpenSavePanelDelegate>
{
SalAquaFilePicker* filePicker;
FilterHelper* filterHelper;
diff --git a/fpicker/source/aqua/SalAquaFilePicker.mm b/fpicker/source/aqua/SalAquaFilePicker.mm
index ac54fca0cc98..3fbe8e7c949a 100644
--- a/fpicker/source/aqua/SalAquaFilePicker.mm
+++ b/fpicker/source/aqua/SalAquaFilePicker.mm
@@ -155,13 +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:
- reinterpret_cast<id (*)(id, SEL, ...)>(objc_msgSend)(
- m_pDialog, @selector(setDelegate:), m_pDelegate);
+ [m_pDialog setDelegate:m_pDelegate];
int nStatus = runandwaitforresult();
More information about the Libreoffice-commits
mailing list