Fix crash in tdehwlib if not exists /sys/devices/system/cpu

This resolves Bug 2584

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/1/head
Slávek Banko 9 years ago
parent 6dfc04c51a
commit f4fb3a8e71

@ -3597,21 +3597,23 @@ void TDEHardwareDevices::addCoreSystemDevices() {
TQDir d("/sys/devices/system/cpu/"); TQDir d("/sys/devices/system/cpu/");
d.setFilter( TQDir::Dirs ); d.setFilter( TQDir::Dirs );
const TQFileInfoList *list = d.entryInfoList(); const TQFileInfoList *list = d.entryInfoList();
TQFileInfoListIterator it( *list ); if (list) {
TQFileInfo *fi; TQFileInfoListIterator it( *list );
while ((fi = it.current()) != 0) { TQFileInfo *fi;
TQString directoryName = fi->fileName(); while ((fi = it.current()) != 0) {
if (directoryName.startsWith("cpu")) { TQString directoryName = fi->fileName();
directoryName = directoryName.remove(0,3); if (directoryName.startsWith("cpu")) {
bool isInt; directoryName = directoryName.remove(0,3);
int processorNumber = directoryName.toUInt(&isInt, 10); bool isInt;
if (isInt) { int processorNumber = directoryName.toUInt(&isInt, 10);
hwdevice = new TDECPUDevice(TDEGenericDeviceType::CPU); if (isInt) {
hwdevice->internalSetSystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber)); hwdevice = new TDECPUDevice(TDEGenericDeviceType::CPU);
m_deviceList.append(hwdevice); hwdevice->internalSetSystemPath(TQString("/sys/devices/system/cpu/cpu%1").arg(processorNumber));
m_deviceList.append(hwdevice);
}
} }
++it;
} }
++it;
} }
// Populate CPU information // Populate CPU information

Loading…
Cancel
Save