Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladiMihaylenko <vxmihaylenko@gmail.com>2017-10-20 18:04:47 +0300
committerDaria Volvenkova <d.volvenkova@corp.mail.ru>2017-10-20 18:14:09 +0300
commitc3c5fde03472a4049b515470e5d91d489e6a9b1a (patch)
treebf42fc191e9f52185160b1bf8a81d4770035d6d3
parentca597b609cb018fa12d0f2565ea4cd5b3f254fb5 (diff)
[ios] Fixed crash after changing bookmark's category.beta-1078beta-1077beta-1076
-rw-r--r--iphone/Maps/Bookmarks/SelectSetVC.h4
-rw-r--r--iphone/Maps/Bookmarks/SelectSetVC.mm21
-rw-r--r--iphone/Maps/UI/EditBookmark/MWMEditBookmarkController.mm21
3 files changed, 26 insertions, 20 deletions
diff --git a/iphone/Maps/Bookmarks/SelectSetVC.h b/iphone/Maps/Bookmarks/SelectSetVC.h
index e9d3258a90..697326e8da 100644
--- a/iphone/Maps/Bookmarks/SelectSetVC.h
+++ b/iphone/Maps/Bookmarks/SelectSetVC.h
@@ -4,14 +4,14 @@ struct BookmarkAndCategory;
@protocol MWMSelectSetDelegate <NSObject>
-- (void)didSelectCategory:(NSString *)category withBac:(BookmarkAndCategory const &)bac;
+- (void)didSelectCategory:(NSString *)category withCategoryIndex:(size_t)categoryIndex;
@end
@interface SelectSetVC : MWMTableViewController
- (instancetype)initWithCategory:(NSString *)category
- bac:(BookmarkAndCategory const &)bac
+ categoryIndex:(size_t)categoryIndex
delegate:(id<MWMSelectSetDelegate>)delegate;
@end
diff --git a/iphone/Maps/Bookmarks/SelectSetVC.mm b/iphone/Maps/Bookmarks/SelectSetVC.mm
index 0d0ed743a7..fbf615db3e 100644
--- a/iphone/Maps/Bookmarks/SelectSetVC.mm
+++ b/iphone/Maps/Bookmarks/SelectSetVC.mm
@@ -7,7 +7,7 @@
@interface SelectSetVC () <AddSetVCDelegate>
{
- BookmarkAndCategory m_bac;
+ size_t m_categoryIndex;
}
@property (copy, nonatomic) NSString * category;
@@ -18,14 +18,14 @@
@implementation SelectSetVC
- (instancetype)initWithCategory:(NSString *)category
- bac:(BookmarkAndCategory const &)bac
+ categoryIndex:(size_t)categoryIndex
delegate:(id<MWMSelectSetDelegate>)delegate
{
self = [super initWithStyle:UITableViewStyleGrouped];
if (self)
{
_category = category;
- m_bac = bac;
+ m_categoryIndex = categoryIndex;
_delegate = delegate;
}
return self;
@@ -36,7 +36,6 @@
[super viewDidLoad];
NSAssert(self.category, @"Category can't be nil!");
NSAssert(self.delegate, @"Delegate can't be nil!");
- NSAssert(m_bac.IsValid(), @"Invalid BookmarkAndCategory's instance!");
self.title = L(@"bookmark_sets");
}
@@ -69,7 +68,7 @@
if (cat)
cell.textLabel.text = @(cat->GetName().c_str());
- if (m_bac.m_categoryIndex == indexPath.row)
+ if (m_categoryIndex == indexPath.row)
cell.accessoryType = UITableViewCellAccessoryCheckmark;
else
cell.accessoryType = UITableViewCellAccessoryNone;
@@ -81,19 +80,13 @@
{
[self moveBookmarkToSetWithIndex:setIndex];
[self.tableView reloadData];
- [self.delegate didSelectCategory:self.category withBac:m_bac];
+ [self.delegate didSelectCategory:self.category withCategoryIndex:setIndex];
}
- (void)moveBookmarkToSetWithIndex:(int)setIndex
{
- BookmarkAndCategory bac;
- bac.m_bookmarkIndex = static_cast<size_t>(
- GetFramework().MoveBookmark(m_bac.m_bookmarkIndex, m_bac.m_categoryIndex, setIndex));
- bac.m_categoryIndex = setIndex;
- m_bac = bac;
-
BookmarkCategory const * category =
- GetFramework().GetBookmarkManager().GetBmCategory(bac.m_categoryIndex);
+ GetFramework().GetBookmarkManager().GetBmCategory(setIndex);
self.category = @(category->GetName().c_str());
}
@@ -109,7 +102,7 @@
else
{
[self moveBookmarkToSetWithIndex:static_cast<int>(indexPath.row)];
- [self.delegate didSelectCategory:self.category withBac:m_bac];
+ [self.delegate didSelectCategory:self.category withCategoryIndex:indexPath.row];
[self backTap];
}
}
diff --git a/iphone/Maps/UI/EditBookmark/MWMEditBookmarkController.mm b/iphone/Maps/UI/EditBookmark/MWMEditBookmarkController.mm
index 06bb0cba1f..c91e856de6 100644
--- a/iphone/Maps/UI/EditBookmark/MWMEditBookmarkController.mm
+++ b/iphone/Maps/UI/EditBookmark/MWMEditBookmarkController.mm
@@ -29,6 +29,7 @@ enum RowInMetaInfo
RowsInMetaInfoCount
};
+static int const kInvalidCategoryIndex = -1;
} // namespace
@interface MWMEditBookmarkController () <MWMButtonCellDelegate, MWMNoteCelLDelegate, MWMBookmarkColorDelegate,
@@ -42,6 +43,7 @@ enum RowInMetaInfo
@property (copy, nonatomic) NSString * cachedTitle;
@property (copy, nonatomic) NSString * cachedColor;
@property (copy, nonatomic) NSString * cachedCategory;
+@property(nonatomic) int64_t cachedCategoryIndex;
@end
@@ -50,6 +52,7 @@ enum RowInMetaInfo
- (void)viewDidLoad
{
[super viewDidLoad];
+ self.cachedCategoryIndex = kInvalidCategoryIndex;
auto data = self.data;
NSAssert(data, @"Data can't be nil!");
self.cachedDescription = data.bookmarkDescription;
@@ -89,12 +92,22 @@ enum RowInMetaInfo
{
[self.view endEditing:YES];
auto & f = GetFramework();
+ if (self.cachedCategoryIndex != kInvalidCategoryIndex)
+ {
+ auto const index = static_cast<size_t>(
+ f.MoveBookmark(m_cachedBookmarkAndCategory.m_bookmarkIndex,
+ m_cachedBookmarkAndCategory.m_categoryIndex,
+ self.cachedCategoryIndex));
+ m_cachedBookmarkAndCategory.m_bookmarkIndex = index;
+ m_cachedBookmarkAndCategory.m_categoryIndex = self.cachedCategoryIndex;
+ }
+
BookmarkCategory * category = f.GetBmCategory(m_cachedBookmarkAndCategory.m_categoryIndex);
if (!category)
return;
auto bookmark = static_cast<Bookmark *>(
- category->GetUserMarkForEdit(m_cachedBookmarkAndCategory.m_bookmarkIndex));
+ category->GetUserMarkForEdit(m_cachedBookmarkAndCategory.m_bookmarkIndex));
if (!bookmark)
return;
@@ -227,7 +240,7 @@ enum RowInMetaInfo
case Category:
{
SelectSetVC * svc = [[SelectSetVC alloc] initWithCategory:self.cachedCategory
- bac:m_cachedBookmarkAndCategory
+ categoryIndex:m_cachedBookmarkAndCategory.m_categoryIndex
delegate:self];
[self.navigationController pushViewController:svc animated:YES];
break;
@@ -273,10 +286,10 @@ enum RowInMetaInfo
#pragma mark - MWMSelectSetDelegate
-- (void)didSelectCategory:(NSString *)category withBac:(BookmarkAndCategory const &)bac
+- (void)didSelectCategory:(NSString *)category withCategoryIndex:(size_t)categoryIndex
{
self.cachedCategory = category;
- m_cachedBookmarkAndCategory = bac;
+ self.cachedCategoryIndex = categoryIndex;
[self.tableView reloadRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:Category inSection:MetaInfo]] withRowAnimation:UITableViewRowAnimationAutomatic];
}