Don't try to use non-existent files
This commit is contained in:
parent
4c243e913d
commit
7603a6d161
1 changed files with 5 additions and 4 deletions
|
@ -205,7 +205,7 @@ Battery::~Battery() {
|
||||||
|
|
||||||
void Battery::updateData()
|
void Battery::updateData()
|
||||||
{
|
{
|
||||||
if(chargeFile->open(QIODevice::ReadOnly)) {
|
if(chargeFile && chargeFile->open(QIODevice::ReadOnly)) {
|
||||||
nextCharge = chargeFile->readLine().trimmed().toInt();
|
nextCharge = chargeFile->readLine().trimmed().toInt();
|
||||||
if(nextCharge != charge) {
|
if(nextCharge != charge) {
|
||||||
charge = nextCharge;
|
charge = nextCharge;
|
||||||
|
@ -213,7 +213,8 @@ void Battery::updateData()
|
||||||
}
|
}
|
||||||
chargeFile->close();
|
chargeFile->close();
|
||||||
}
|
}
|
||||||
if(chargerConnectedFile->open(QIODevice::ReadOnly)) {
|
|
||||||
|
if(chargerConnectedFile && chargerConnectedFile->open(QIODevice::ReadOnly)) {
|
||||||
nextChargerConnected = chargerConnectedFile->readLine().trimmed().toInt();
|
nextChargerConnected = chargerConnectedFile->readLine().trimmed().toInt();
|
||||||
if(nextChargerConnected != chargerConnected) {
|
if(nextChargerConnected != chargerConnected) {
|
||||||
chargerConnected = nextChargerConnected;
|
chargerConnected = nextChargerConnected;
|
||||||
|
@ -222,7 +223,7 @@ void Battery::updateData()
|
||||||
chargerConnectedFile->close();
|
chargerConnectedFile->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentFile->open(QIODevice::ReadOnly)) {
|
if(currentFile && currentFile->open(QIODevice::ReadOnly)) {
|
||||||
nextCurrent = currentFile->readLine().trimmed().toInt();
|
nextCurrent = currentFile->readLine().trimmed().toInt();
|
||||||
if(nextCurrent != current) {
|
if(nextCurrent != current) {
|
||||||
current = nextCurrent;
|
current = nextCurrent;
|
||||||
|
@ -231,7 +232,7 @@ void Battery::updateData()
|
||||||
currentFile->close();
|
currentFile->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(stateFile->open(QIODevice::ReadOnly)) {
|
if(stateFile && stateFile->open(QIODevice::ReadOnly)) {
|
||||||
nextState = (QString(stateFile->readLine().trimmed().toLower()));
|
nextState = (QString(stateFile->readLine().trimmed().toLower()));
|
||||||
if(nextState != state) {
|
if(nextState != state) {
|
||||||
state = nextState;
|
state = nextState;
|
||||||
|
|
Loading…
Reference in a new issue