diff options
Diffstat (limited to 'base/files')
-rw-r--r-- | base/files/file_path_watcher_linux.cc | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/base/files/file_path_watcher_linux.cc b/base/files/file_path_watcher_linux.cc index aa116e3..265366b 100644 --- a/base/files/file_path_watcher_linux.cc +++ b/base/files/file_path_watcher_linux.cc @@ -404,19 +404,21 @@ void FilePathWatcherImpl::Cancel() { } void FilePathWatcherImpl::CancelOnMessageLoopThread() { - if (!is_cancelled()) { + if (!is_cancelled()) set_cancelled(); - MessageLoop::current()->RemoveDestructionObserver(this); - for (WatchVector::iterator watch_entry(watches_.begin()); - watch_entry != watches_.end(); ++watch_entry) { - if (watch_entry->watch_ != InotifyReader::kInvalidWatch) - g_inotify_reader.Get().RemoveWatch(watch_entry->watch_, this); - } - watches_.clear(); + if (delegate_) { + MessageLoop::current()->RemoveDestructionObserver(this); delegate_ = NULL; - target_.clear(); } + + for (WatchVector::iterator watch_entry(watches_.begin()); + watch_entry != watches_.end(); ++watch_entry) { + if (watch_entry->watch_ != InotifyReader::kInvalidWatch) + g_inotify_reader.Get().RemoveWatch(watch_entry->watch_, this); + } + watches_.clear(); + target_.clear(); } void FilePathWatcherImpl::WillDestroyCurrentMessageLoop() { |