修复闪退问题

This commit is contained in:
lizhuoan 2023-06-08 09:03:16 +08:00 committed by Yue-Lan
parent 83c5de2ca3
commit 8976800284
2 changed files with 16 additions and 9 deletions

View File

@ -368,7 +368,9 @@ int DataCDROM::checkMediumType()
0};
unsigned char result[65536] = {0};
m_oMediumType.clear();
if (!m_oMediumType.isEmpty()) {
m_oMediumType.clear();
}
if (!execSCSI(cdb, 12, result, 12)) {
qWarning()<<"scsi get medium type failed";
@ -532,10 +534,10 @@ void DataCDROM::DVDRWCapacity()
QStringList deviceName;
deviceName<<m_oBlockName;
DvdMediaInfoFetcher* fetcher = new DvdMediaInfoFetcher(deviceName);
DvdMediaInfoFetcher* fetcher = new DvdMediaInfoFetcher(deviceName, m_oMediumType);
QThread* thread = new QThread;
fetcher->moveToThread(thread);
connect(fetcher, &DvdMediaInfoFetcher::resultReady, [=](const QString& result) {
connect(fetcher, &DvdMediaInfoFetcher::resultReady, [=](const QString& result, const QString& type) {
QString data = result;
QStringList ss = data.split("\n");
QStringList sss;
@ -546,13 +548,13 @@ void DataCDROM::DVDRWCapacity()
if (ss.at(i).startsWith("READ FORMAT CAPACITIES:")) break;
}
if (m_oMediumType.contains("DVD+RW") && ss.size() >= i+1)
if (type.contains("DVD+RW") && ss.size() >= i+1)
{
ss = ss.takeAt(i + 1).split("=");
//ss = ss.last().split("=");
m_u64Capacity = ss.last().toULong();
}
if (m_oMediumType.contains("DVD-RW") && ss.size() >= i+2)
if (type.contains("DVD-RW") && ss.size() >= i+2)
{
//解决bug:70940和83628擦除后总容量显示错误
#if 0
@ -572,6 +574,7 @@ void DataCDROM::DVDRWCapacity()
auto t = sss.last().toULong();
m_u64Capacity = t;
#endif
Q_EMIT getInfoFinished(t);
}
});
connect(thread, &QThread::started, fetcher, &DvdMediaInfoFetcher::fetch);
@ -659,6 +662,6 @@ void DvdMediaInfoFetcher::fetch()
process.start("/usr/bin/dvd+rw-mediainfo", m_deviceName);
process.waitForFinished(-1); // Wait indefinitely for the process to finish.
QString result = process.readAllStandardOutput();
Q_EMIT resultReady(result);
Q_EMIT resultReady(result, m_deviceType);
Q_EMIT finished();
}

View File

@ -94,6 +94,9 @@ public:
return m_oMediumType;
}
Q_SIGNALS:
void getInfoFinished(const unsigned long& CapacitySize);
private:
bool open();
void close();
@ -123,11 +126,11 @@ private:
class DvdMediaInfoFetcher : public QObject {
Q_OBJECT
public:
explicit DvdMediaInfoFetcher(const QStringList& deviceName, QObject* parent = nullptr)
: QObject(parent), m_deviceName(deviceName) {}
explicit DvdMediaInfoFetcher(const QStringList& deviceName, const QString& deviceType, QObject* parent = nullptr)
: QObject(parent), m_deviceName(deviceName), m_deviceType(deviceType) {}
Q_SIGNALS:
void resultReady(const QString& result);
void resultReady(const QString& result, const QString& type);
void finished();
public Q_SLOTS:
@ -135,6 +138,7 @@ public Q_SLOTS:
private:
QStringList m_deviceName;
QString m_deviceType;
};
#endif // DATACDROM_H