Fix SCM callback crash

Since we retained the SCM info in an asynchronous block, we would potentially extend the lifetime of the SCM info and thus the associated callback, so the callback could be invoked after its owner had been disposed.
This commit is contained in:
Allan Odgaard
2013-02-16 10:17:49 +01:00
parent 81c5c40ae5
commit 80618b3e33

View File

@@ -165,7 +165,7 @@ private:
add_item_and_children(child, array);
}
static void async_reload (FSDirectoryDataSource* dataSource, FSItem* rootItem, scm::ng::info_ptr scmInfo, bool reloadWasRequested)
static void async_reload (FSDirectoryDataSource* dataSource, FSItem* rootItem, scm::ng::weak_info_ptr weakSCMInfo, bool reloadWasRequested)
{
std::string const dir = to_s([rootItem.url path]);
bool includeHidden = (dataSource.dataSourceOptions & kFSDataSourceOptionIncludeHidden) == kFSDataSourceOptionIncludeHidden;
@@ -209,6 +209,7 @@ private:
existingItems.insert(std::make_pair(std::make_pair(item.device, item.inode), item));
std::set<std::string> pathsOnDisk;
scm::ng::info_ptr scmInfo = weakSCMInfo.lock();
NSMutableArray* array = [NSMutableArray array];
for(auto const& fsItem : newItems)