Skip to content

Commit

Permalink
Fix a crash when UIPasteboard returns hasImages is true but image pro…
Browse files Browse the repository at this point in the history
…perty isn't available
  • Loading branch information
c99koder committed Nov 8, 2023
1 parent b21bf34 commit 2f30cd8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 6 additions & 0 deletions IRCCloud.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3516,6 +3516,7 @@
"${BUILT_PRODUCTS_DIR}/FirebaseMessaging/FirebaseMessaging.framework",
"${BUILT_PRODUCTS_DIR}/FirebasePerformance/FirebasePerformance.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseRemoteConfig/FirebaseRemoteConfig.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseSharedSwift/FirebaseSharedSwift.framework",
"${BUILT_PRODUCTS_DIR}/youtube-ios-player-helper/youtube_ios_player_helper.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -3533,6 +3534,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseMessaging.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebasePerformance.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseRemoteConfig.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseSharedSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/youtube_ios_player_helper.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -3582,6 +3584,7 @@
"${BUILT_PRODUCTS_DIR}/FirebaseMessaging/FirebaseMessaging.framework",
"${BUILT_PRODUCTS_DIR}/FirebasePerformance/FirebasePerformance.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseRemoteConfig/FirebaseRemoteConfig.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseSharedSwift/FirebaseSharedSwift.framework",
"${BUILT_PRODUCTS_DIR}/youtube-ios-player-helper/youtube_ios_player_helper.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -3599,6 +3602,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseMessaging.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebasePerformance.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseRemoteConfig.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseSharedSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/youtube_ios_player_helper.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -3648,6 +3652,7 @@
"${BUILT_PRODUCTS_DIR}/FirebaseMessaging/FirebaseMessaging.framework",
"${BUILT_PRODUCTS_DIR}/FirebasePerformance/FirebasePerformance.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseRemoteConfig/FirebaseRemoteConfig.framework",
"${BUILT_PRODUCTS_DIR}/FirebaseSharedSwift/FirebaseSharedSwift.framework",
"${BUILT_PRODUCTS_DIR}/youtube-ios-player-helper/youtube_ios_player_helper.framework",
);
name = "[CP] Embed Pods Frameworks";
Expand All @@ -3665,6 +3670,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseMessaging.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebasePerformance.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseRemoteConfig.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FirebaseSharedSwift.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/youtube_ios_player_helper.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
16 changes: 7 additions & 9 deletions IRCCloud/Classes/MainViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -5472,15 +5472,13 @@ -(void)closeColorPicker {
}

-(void)paste:(id)sender {
if([UIPasteboard generalPasteboard].hasImages && ![UIPasteboard generalPasteboard].hasURLs) {
for(NSString *type in [UIPasteboard generalPasteboard].pasteboardTypes) {
if([type isEqualToString:(__bridge NSString *)kUTTypeGIF] && [UIPasteboard generalPasteboard].image) {
UIImage *img = [UIPasteboard generalPasteboard].image;
NSData *gifData = [[UIPasteboard generalPasteboard] dataForPasteboardType:(__bridge NSString *)kUTTypeGIF];
if(img != nil && gifData != nil)
[self _imagePickerController:[UIImagePickerController new] didFinishPickingMediaWithInfo:@{UIImagePickerControllerOriginalImage:img, @"gifData":gifData}];
return;
}
if([UIPasteboard generalPasteboard].hasImages && [UIPasteboard generalPasteboard].image && ![UIPasteboard generalPasteboard].hasURLs) {
if([UIPasteboard generalPasteboard].image && [[UIPasteboard generalPasteboard] containsPasteboardTypes:@[(__bridge NSString *)kUTTypeGIF]]) {
UIImage *img = [UIPasteboard generalPasteboard].image;
NSData *gifData = [[UIPasteboard generalPasteboard] dataForPasteboardType:(__bridge NSString *)kUTTypeGIF];
if(img != nil && gifData != nil)
[self _imagePickerController:[UIImagePickerController new] didFinishPickingMediaWithInfo:@{UIImagePickerControllerOriginalImage:img, @"gifData":gifData}];
return;
}
[self _imagePickerController:[UIImagePickerController new] didFinishPickingMediaWithInfo:@{UIImagePickerControllerOriginalImage:[UIPasteboard generalPasteboard].image}];
} else if([UIPasteboard generalPasteboard].hasStrings) {
Expand Down

0 comments on commit 2f30cd8

Please sign in to comment.