File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,14 @@ - (void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEdi
251251 if (editingStyle == UITableViewCellEditingStyleDelete) {
252252 [AppDelegate.instance.arrayServerList removeObjectAtIndex: indexPath.row];
253253 [AppDelegate.instance saveServerList ];
254+ if (indexPath.row < [tableView numberOfRowsInSection: indexPath.section]) {
255+ [tableView performBatchUpdates: ^{
256+ [tableView deleteRowsAtIndexPaths: @[indexPath] withRowAnimation: UITableViewRowAnimationRight];
257+ } completion: nil ];
258+ }
259+
260+ // Be aware! Sending "XBMCServerHasChanged" results in calling reloadData. Therefore ensure this is not called
261+ // between updating arrayServerList and changing tableView to avoid a crash due to inconsistent amount of rows.
254262 NSIndexPath *selectedPath = storeServerSelection;
255263 if (selectedPath) {
256264 if (indexPath.row < selectedPath.row ) {
@@ -266,11 +274,6 @@ - (void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEdi
266274 [[NSNotificationCenter defaultCenter ] postNotificationName: @" XBMCServerHasChanged" object: nil ];
267275 }
268276 }
269- if (indexPath.row < [tableView numberOfRowsInSection: indexPath.section]) {
270- [tableView performBatchUpdates: ^{
271- [tableView deleteRowsAtIndexPaths: @[indexPath] withRowAnimation: UITableViewRowAnimationRight];
272- } completion: nil ];
273- }
274277 // Are there still editable entries?
275278 editTableButton.selected = editTableButton.enabled = AppDelegate.instance .arrayServerList .count > 0 ;
276279 }
You can’t perform that action at this time.
0 commit comments