Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix potential crash

Even though the code is running on the main thread, it might still run after the owning (C++) object has been destroyed.
  • Loading branch information...
commit fce82f07597314cb979d3f56b5c26a1b0fc4e717 1 parent cafb518
@sorbits sorbits authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.mm
View
7 Frameworks/OakFileBrowser/src/io/FSDirectoryDataSource.mm
@@ -51,9 +51,11 @@ - (void)lostItems:(NSArray*)someItems;
if(_scm_info)
{
- _scm_info->add_callback(^(scm::ng::info_t const& info){
+ _live.reset(new bool{true});
+ std::weak_ptr<bool> isAlive = _live;
- if(!_item.children)
+ _scm_info->add_callback(^(scm::ng::info_t const& info){
+ if(!isAlive.lock() || !_item.children)
return;
std::set<std::string> pathsShown, pathsDeleted, pathsMissingOnDisk;
@@ -293,6 +295,7 @@ void internal_reload (bool reloadWasRequested)
std::string _path;
struct timespec _last_modified;
scm::ng::info_ptr _scm_info;
+ std::shared_ptr<bool> _live;
};
@implementation FSDirectoryDataSource
Please sign in to comment.
Something went wrong with that request. Please try again.