Skip to content

Commit 0d23132

Browse files
committed
fix(QrcodeStream): camera active after destroy
See #80
1 parent e8faa4f commit 0d23132

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/components/QrcodeReader.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ export default {
210210
this.cameraInstance = null
211211
} else {
212212
this.cameraInstance = await Camera(this.constraints, this.$refs.video)
213+
214+
// if the component is destroyed before `cameraInstance` resolves a
215+
// `beforeDestroy` hook has no chance to clear the remaining camera
216+
// stream.
217+
if (this.destroyed) {
218+
this.cameraInstance.stop()
219+
}
213220
}
214221
},
215222

src/components/QrcodeStream.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,13 @@ export default {
186186
this.cameraInstance = null
187187
} else {
188188
this.cameraInstance = await Camera(this.constraints, this.$refs.video)
189+
190+
// if the component is destroyed before `cameraInstance` resolves a
191+
// `beforeDestroy` hook has no chance to clear the remaining camera
192+
// stream.
193+
if (this.destroyed) {
194+
this.cameraInstance.stop()
195+
}
189196
}
190197
},
191198

0 commit comments

Comments
 (0)