diff options
author | rowanbeentje <rowan@beent.je> | 2014-02-06 00:00:37 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2014-02-06 00:00:37 +0000 |
commit | 38ca716543d7601a4e29823fb4578b96c599cf81 (patch) | |
tree | 94fd4f4c90217d8b26366d5893788a607ec7f57f /Source/SPDataStorage.m | |
parent | 1d8db00d8fc0ef855b6308de8c9c66faa70f7d05 (diff) | |
download | sequelpro-38ca716543d7601a4e29823fb4578b96c599cf81.tar.gz sequelpro-38ca716543d7601a4e29823fb4578b96c599cf81.tar.bz2 sequelpro-38ca716543d7601a4e29823fb4578b96c599cf81.zip |
Improve thread safety of SPDataStorage NSPointerArray tracking to further improve #1884 and fix count tracking when removing a single row
Diffstat (limited to 'Source/SPDataStorage.m')
-rw-r--r-- | Source/SPDataStorage.m | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/Source/SPDataStorage.m b/Source/SPDataStorage.m index 981e48f5..c5c86544 100644 --- a/Source/SPDataStorage.m +++ b/Source/SPDataStorage.m @@ -57,8 +57,8 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore - (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 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore // Remove the row from the edited list and underlying storage if (anIndex < editedRowCount) { + editedRowCount--; [editedRows removePointerAtIndex:anIndex]; } [dataStorage removeRowAtIndex:anIndex]; @@ -363,8 +364,8 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore // 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 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore */ - (void) removeAllRows { - [editedRows setCount:0]; editedRowCount = 0; + [editedRows setCount:0]; [dataStorage removeAllRows]; } @@ -426,8 +427,8 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore */ - (void)resultStoreDidFinishLoadingData:(SPMySQLStreamingResultStore *)resultStore { - editedRowCount = [resultStore numberOfRows]; - [editedRows setCount:editedRowCount]; + [editedRows setCount:[resultStore numberOfRows]]; + editedRowCount = [editedRows count]; } /** |