mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-28 15:22:39 +00:00
Remove NSException from RiotShareExtension
Fix some retain cycles and early releases.
This commit is contained in:
parent
6fd2f2c3a2
commit
bb8f330ca0
3 changed files with 12 additions and 8 deletions
|
@ -34,6 +34,12 @@
|
|||
@property (nonatomic, strong) MXKAccount *userAccount;
|
||||
@property (nonatomic, strong) MXFileStore *fileStore;
|
||||
|
||||
/**
|
||||
An array of rooms that the item is being shared to. This is to maintain a strong ref
|
||||
to all necessary `MXRoom`s until sharing has completed.
|
||||
*/
|
||||
@property (nonatomic, strong) NSMutableArray<MXRoom *> *selectedRooms;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -94,17 +100,19 @@
|
|||
|
||||
session.crypto.warnOnUnknowDevices = NO; // Do not warn for unknown devices. We have cross-signing now
|
||||
|
||||
NSMutableArray<MXRoom *> *rooms = [NSMutableArray array];
|
||||
self.selectedRooms = [NSMutableArray array];
|
||||
for (NSString *roomIdentifier in roomIdentifiers) {
|
||||
MXRoom *room = [MXRoom loadRoomFromStore:self.fileStore withRoomId:roomIdentifier matrixSession:session];
|
||||
if (room) {
|
||||
[rooms addObject:room];
|
||||
[self.selectedRooms addObject:room];
|
||||
}
|
||||
}
|
||||
|
||||
[self.shareItemSender sendItemsToRooms:rooms success:^{
|
||||
[self.shareItemSender sendItemsToRooms:self.selectedRooms success:^{
|
||||
self.selectedRooms = nil;
|
||||
self.completionCallback(ShareManagerResultFinished);
|
||||
} failure:^(NSArray<NSError *> *errors) {
|
||||
self.selectedRooms = nil;
|
||||
[self showFailureAlert:[VectorL10n roomEventFailedToSend]];
|
||||
}];
|
||||
|
||||
|
|
|
@ -99,10 +99,6 @@
|
|||
{
|
||||
[self dismissViewControllerAnimated:true completion:^{
|
||||
[self.presentingViewController dismissViewControllerAnimated:false completion:nil];
|
||||
|
||||
// FIXME: Share extension memory usage increase when launched several times and then crash due to some memory leaks.
|
||||
// For now, we force the share extension to exit and free memory.
|
||||
[NSException raise:@"Kill the app extension" format:@"Free memory used by share extension"];
|
||||
}];
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ typedef NS_ENUM(NSInteger, ImageCompressionMode)
|
|||
|
||||
@interface ShareItemSender ()
|
||||
|
||||
@property (nonatomic, strong, readonly) UIViewController *rootViewController;
|
||||
@property (nonatomic, weak, readonly) UIViewController *rootViewController;
|
||||
@property (nonatomic, strong, readonly) ShareExtensionShareItemProvider *shareItemProvider;
|
||||
|
||||
@property (nonatomic, strong, readonly) NSMutableArray<NSData *> *pendingImages;
|
||||
|
|
Loading…
Reference in a new issue