| @@ -65,7 +65,7 @@ inline int getAddressDifference (Type1* pointer1, Type2* pointer2) noexcept { r | |||||
| nullptr if the pointer is null. | nullptr if the pointer is null. | ||||
| */ | */ | ||||
| template <class Type> | template <class Type> | ||||
| inline Type* createCopyIfNotNull (Type* pointer) { return pointer != nullptr ? new Type (*pointer) : nullptr; } | |||||
| inline Type* createCopyIfNotNull (const Type* pointer) { return pointer != nullptr ? new Type (*pointer) : nullptr; } | |||||
| //============================================================================== | //============================================================================== | ||||
| #if JUCE_MAC || JUCE_IOS || DOXYGEN | #if JUCE_MAC || JUCE_IOS || DOXYGEN | ||||
| @@ -128,6 +128,18 @@ public: | |||||
| return dest; | return dest; | ||||
| } | } | ||||
| static CharPointerType createFromCharPointer (const CharPointerType& start, const CharPointerType& end) | |||||
| { | |||||
| if (start.getAddress() == nullptr || start.isEmpty()) | |||||
| return getEmpty(); | |||||
| const size_t numBytes = end.getAddress() - start.getAddress(); | |||||
| const CharPointerType dest (createUninitialisedBytes (numBytes + 1)); | |||||
| memcpy (dest.getAddress(), start, numBytes); | |||||
| dest.getAddress()[numBytes] = 0; | |||||
| return dest; | |||||
| } | |||||
| static CharPointerType createFromFixedLength (const char* const src, const size_t numChars) | static CharPointerType createFromFixedLength (const char* const src, const size_t numChars) | ||||
| { | { | ||||
| const CharPointerType dest (createUninitialisedBytes (numChars * sizeof (CharType) + sizeof (CharType))); | const CharPointerType dest (createUninitialisedBytes (numChars * sizeof (CharType) + sizeof (CharType))); | ||||
| @@ -61,8 +61,7 @@ public: | |||||
| menuBarItemsChanged (nullptr); | menuBarItemsChanged (nullptr); | ||||
| } | } | ||||
| extraAppleMenuItems = newExtraAppleMenuItems != nullptr ? new PopupMenu (*newExtraAppleMenuItems) | |||||
| : nullptr; | |||||
| extraAppleMenuItems = createCopyIfNotNull (newExtraAppleMenuItems); | |||||
| } | } | ||||
| void addSubMenu (NSMenu* parent, const PopupMenu& child, | void addSubMenu (NSMenu* parent, const PopupMenu& child, | ||||