Permalink
Browse files

Improve thread safety of SPDataStorage NSPointerArray tracking to fur…

…ther improve #1884 and fix count tracking when removing a single row
  • Loading branch information...
rowanbeentje committed Feb 6, 2014
1 parent 1d8db00 commit 38ca716543d7601a4e29823fb4578b96c599cf81
Showing with 6 additions and 5 deletions.
  1. +6 −5 Source/SPDataStorage.m
@@ -57,8 +57,8 @@ @implementation SPDataStorage
- (void) setDataStorage:(SPMySQLStreamingResultStore *)newDataStorage updatingExisting:(BOOL)updateExistingStore
{
NSUInteger i;
[editedRows release], editedRows = nil;
editedRowCount = 0;
[editedRows release], editedRows = nil;
if (unloadedColumns) free(unloadedColumns), unloadedColumns = NULL;
if (dataStorage) {
@@ -343,6 +343,7 @@ - (void) removeRowAtIndex:(NSUInteger)anIndex
// Remove the row from the edited list and underlying storage
if (anIndex < editedRowCount) {
editedRowCount--;
[editedRows removePointerAtIndex:anIndex];
}
[dataStorage removeRowAtIndex:anIndex];
@@ -363,8 +364,8 @@ - (void) removeRowsInRange:(NSRange)rangeToRemove
// Remove the rows from the edited list and underlying storage
NSUInteger i = MIN(editedRowCount, rangeToRemove.location + rangeToRemove.length);
while (--i >= rangeToRemove.location) {
[editedRows removePointerAtIndex:i];
editedRowCount--;
[editedRows removePointerAtIndex:i];
}
[dataStorage removeRowsInRange:rangeToRemove];
}
@@ -374,8 +375,8 @@ - (void) removeRowsInRange:(NSRange)rangeToRemove
*/
- (void) removeAllRows
{
[editedRows setCount:0];
editedRowCount = 0;
[editedRows setCount:0];
[dataStorage removeAllRows];
}
@@ -426,8 +427,8 @@ - (BOOL) dataDownloaded
*/
- (void)resultStoreDidFinishLoadingData:(SPMySQLStreamingResultStore *)resultStore
{
editedRowCount = [resultStore numberOfRows];
[editedRows setCount:editedRowCount];
[editedRows setCount:[resultStore numberOfRows]];
editedRowCount = [editedRows count];
}
/**

0 comments on commit 38ca716

Please sign in to comment.