Skip to content

Commit b73fb18

Browse files
committed
Destroy the stream before the camera
1 parent 8371679 commit b73fb18

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

aravisApp/src/ADAravis.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,19 @@ void ADAravis::shutdownPortDriver() {
409409
pollingLoop.exitWait();
410410

411411
ADGenICam::shutdownPortDriver();
412+
413+
// This would normally go in the destructor. But on old versions of asyn,
414+
// the driver is not deleted after shutdown completes, and the following
415+
// steps are needed to disconnect the camera.
416+
arv_stream_set_emit_signals(stream, false);
417+
g_object_unref(stream);
418+
g_object_unref(camera);
419+
420+
// This makes it easier to find use-after-free.
421+
stream = NULL;
422+
genicam = NULL;
423+
device = NULL;
424+
camera = NULL;
412425
}
413426

414427
ADAravis::~ADAravis() {
@@ -419,9 +432,6 @@ ADAravis::~ADAravis() {
419432
if (!exiting) {
420433
shutdownPortDriver();
421434
}
422-
423-
g_object_unref(camera);
424-
camera = NULL;
425435
}
426436

427437
asynStatus ADAravis::makeCameraObject() {

0 commit comments

Comments
 (0)