Fix crash

This commit is contained in:
Li 2023-03-15 21:13:58 +13:00
parent 98b5577a9a
commit 079cb1129e
1 changed files with 6 additions and 5 deletions

View File

@ -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<Li::Scsi::OpticalDrive*>* 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;