Skip to content

Commit

Permalink
- fixes API MISUSE when calling stopScan on dispose (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Janeczek committed Sep 11, 2018
1 parent 6318aa2 commit 27a7192
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Source/CentralManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ public class CentralManager: ManagerType {
return Disposables.create { [weak self] in
guard let strongSelf = self else { return }
// When disposed, stop scan and dispose scanning
strongSelf.manager.stopScan()
if strongSelf.state == .poweredOn {
strongSelf.manager.stopScan()
}
do { strongSelf.lock.lock(); defer { strongSelf.lock.unlock() }
strongSelf.scanDisposable?.dispose()
strongSelf.scanDisposable = nil
Expand Down

0 comments on commit 27a7192

Please sign in to comment.