diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-09-30 14:55:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 14:55:04 +0200 |
commit | 3a19400889d518e35e69087588195328bcda9f8e (patch) | |
tree | 5c5eada331f5a8639d043e9dd53e699792c8534a /platform | |
parent | 998974fd7af6e720cb00898071d3050f7e019ccb (diff) | |
parent | 11ccfad1aabec468fd92e1b567f3f9d94b5acc4b (diff) |
Merge pull request #48685 from bruvzg/bundle_icon_4
Diffstat (limited to 'platform')
-rw-r--r-- | platform/osx/os_osx.h | 1 | ||||
-rw-r--r-- | platform/osx/os_osx.mm | 20 |
2 files changed, 17 insertions, 4 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index df41ccd892..a52436a70a 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -82,6 +82,7 @@ public: virtual String get_data_path() const override; virtual String get_cache_path() const override; virtual String get_bundle_resource_dir() const override; + virtual String get_bundle_icon_path() const override; virtual String get_godot_dir_name() const override; virtual String get_system_dir(SystemDir p_dir, bool p_shared_storage = true) const override; diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index c6e35fee83..6ef1bdbd11 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -379,14 +379,26 @@ String OS_OSX::get_cache_path() const { } String OS_OSX::get_bundle_resource_dir() const { + String ret; + NSBundle *main = [NSBundle mainBundle]; - NSString *resourcePath = [main resourcePath]; + if (main) { + NSString *resourcePath = [main resourcePath]; + ret.parse_utf8([resourcePath UTF8String]); + } + return ret; +} - char *utfs = strdup([resourcePath UTF8String]); +String OS_OSX::get_bundle_icon_path() const { String ret; - ret.parse_utf8(utfs); - free(utfs); + NSBundle *main = [NSBundle mainBundle]; + if (main) { + NSString *iconPath = [[main infoDictionary] objectForKey:@"CFBundleIconFile"]; + if (iconPath) { + ret.parse_utf8([iconPath UTF8String]); + } + } return ret; } |