From 079cb1129ef3cec4de2339bbdbc99e308a75aad4 Mon Sep 17 00:00:00 2001
From: Li
Date: Wed, 15 Mar 2023 21:13:58 +1300
Subject: [PATCH] Fix crash
---
DumpDVD/Gui/DumpDVD.cpp | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/DumpDVD/Gui/DumpDVD.cpp b/DumpDVD/Gui/DumpDVD.cpp
index d5f4e99..737d7f3 100644
--- a/DumpDVD/Gui/DumpDVD.cpp
+++ b/DumpDVD/Gui/DumpDVD.cpp
@@ -50,6 +50,7 @@ namespace Li::Gui {
DumpDVD::~DumpDVD() {
this->keepPolling = false;
this->pollDrives->join();
+ delete this->lock;
delete this->pollDrives;
freeOldDriveList();
}
@@ -101,17 +102,19 @@ namespace Li::Gui {
void DumpDVD::pollDrivesThread() {
while (this->keepPolling) {
if ( (this->counter % (60 * 10)) == 0) {
- this->lock->lock();
this->refreshDriveList();
- this->lock->unlock();
}
}
}
void DumpDVD::refreshDriveList() {
std::vector* pollDrives = Li::Scsi::OpticalDrive::ListOpticalDrives();
- freeOldDriveList();
+ if(this->lock != nullptr)
+ this->lock->lock();
+ this->freeOldDriveList();
this->drivesList = pollDrives;
+ if (this->lock != nullptr)
+ this->lock->unlock();
}
void DumpDVD::freeOldDriveList() {
@@ -156,10 +159,8 @@ namespace Li::Gui {
}
void DumpDVD::startRip() {
- refreshDriveList();
if (this->GetCurrentSelectedDrive()->DiscInDrive()) {
this->keepPolling = false;
-
this->pollDrives->join();
delete this->pollDrives;