Просмотр исходного кода

little error and debug cleanups

Malte Veerman 10 лет назад
Родитель
Сommit
aa9ff6c8ce
6 измененных файлов с 19 добавлено и 22 удалено
  1. 1 1
      CMakeLists.txt
  2. 2 2
      lib/src/fan.cpp
  3. 2 2
      lib/src/loader.cpp
  4. 9 9
      lib/src/pwmfan.cpp
  5. 3 6
      lib/src/systemdcommunicator.cpp
  6. 2 2
      lib/src/temp.cpp

+ 1 - 1
CMakeLists.txt

@@ -110,7 +110,7 @@ endif(INSTALL_SHARED)
 
 
 #run tests
-add_subdirectory(tests)
+# add_subdirectory(tests)
 
 
 #summary

+ 2 - 2
lib/src/fan.cpp

@@ -45,7 +45,7 @@ Fan::Fan(Hwmon *parent, uint index) :
             *m_rpmStream >> m_rpm;
         }
         else
-            qDebug() << "Can't open rpmFile " << parent->path() + "/fan" + QString::number(index) + "_input";
+            qWarning() << "Can't open rpmFile " << parent->path() + "/fan" + QString::number(index) + "_input";
     }
 }
 
@@ -92,7 +92,7 @@ void Fan::reset()
             *m_rpmStream >> m_rpm;
         }
         else
-            qDebug() << "Can't open rpmFile " << m_parent->path() + "/fan" + QString::number(m_index) + "_input";
+            qWarning() << "Can't open rpmFile " << m_parent->path() + "/fan" + QString::number(m_index) + "_input";
     }
 }
 

+ 2 - 2
lib/src/loader.cpp

@@ -109,7 +109,7 @@ void Loader::parseHwmons()
 
     else
     {
-        qDebug() << HWMON_PATH << " is not readable!";
+        qCritical() << HWMON_PATH << " is not readable!";
         return;
     }
     
@@ -634,5 +634,5 @@ void Loader::setError (const QString &error)
         emit errorChanged();
         
     }
-    qDebug() << error;
+    qWarning() << error;
 }

+ 9 - 9
lib/src/pwmfan.cpp

@@ -76,7 +76,7 @@ PwmFan::PwmFan(Hwmon *parent, uint index) : Fan(parent, index),
             *m_pwmStream >> m_pwm;
         }
         else
-            qDebug() << "Can't open pwmFile " << pwmFile->fileName();
+            qWarning() << "Can't open pwmFile " << pwmFile->fileName();
 
         QFile *pwmModeFile = new QFile(parent->path() + "/pwm" + QString::number(index) + "_mode", this);
         if (pwmModeFile->open(QFile::ReadWrite))
@@ -90,7 +90,7 @@ PwmFan::PwmFan(Hwmon *parent, uint index) : Fan(parent, index),
             *m_modeStream >> m_pwmMode;
         }
         else
-            qDebug() << "Can't open pwmModeFile " << pwmModeFile->fileName();
+            qWarning() << "Can't open pwmModeFile " << pwmModeFile->fileName();
     }
 }
 
@@ -135,7 +135,7 @@ void PwmFan::reset()
             *m_pwmStream >> m_pwm;
         }
         else
-            qDebug() << "Can't open pwmFile " << pwmFile->fileName();
+            qWarning() << "Can't open pwmFile " << pwmFile->fileName();
 
         QFile *pwmModeFile = new QFile(m_parent->path() + "/pwm" + QString::number(m_index) + "_mode", this);
         if (pwmModeFile->open(QFile::ReadWrite))
@@ -149,7 +149,7 @@ void PwmFan::reset()
             *m_modeStream >> m_pwmMode;
         }
         else
-            qDebug() << "Can't open pwmModeFile " << pwmModeFile->fileName();
+            qWarning() << "Can't open pwmModeFile " << pwmModeFile->fileName();
 }
 
 bool PwmFan::setPwm(int pwm, bool write)
@@ -169,7 +169,7 @@ bool PwmFan::setPwm(int pwm, bool write)
                 action.setHelperId("fancontrol.gui.helper");
                 if (!action.isValid())
                 {
-                    qDebug() << "setPwm action is invalid";
+                    qCritical() << "setPwm action is invalid";
                     return false;
                 }
                 
@@ -182,7 +182,7 @@ bool PwmFan::setPwm(int pwm, bool write)
 
                 if (!reply->exec())
                 {
-                    qDebug() << "setPwm error:" << reply->errorString() << reply->errorText();
+                    qCritical() << "setPwm error:" << reply->errorString() << reply->errorText();
                     return false;
                 }
             }
@@ -209,7 +209,7 @@ bool PwmFan::setPwmMode(int pwmMode, bool write)
                 action.setHelperId("fancontrol.gui.helper");
                 if (!action.isValid())
                 {
-                    qDebug() << "setPwmMode action is invalid";
+                    qCritical() << "setPwmMode action is invalid";
                     return false;
                 }
                 
@@ -222,7 +222,7 @@ bool PwmFan::setPwmMode(int pwmMode, bool write)
 
                 if (!reply->exec())
                 {
-                    qDebug() << "setPwmMode error:" << reply->errorString() << reply->errorText();
+                    qCritical() << "setPwmMode error:" << reply->errorString() << reply->errorText();
                     return false;
                 }
             }
@@ -243,7 +243,7 @@ bool PwmFan::test()
     }
     else
     {
-        qDebug() << "Testing failed";
+        qCritical() << "Testing failed";
         return false;
     }
     

+ 3 - 6
lib/src/systemdcommunicator.cpp

@@ -128,8 +128,7 @@ bool SystemdCommunicator::serviceExists()
 
     if (dbusreply.type() == QDBusMessage::ErrorMessage)
     {
-        m_error = dbusreply.errorMessage();
-        emit errorChanged();
+        setError(dbusreply.errorMessage());
         return false;
     }
     SystemdUnitFileList list = qdbus_cast<SystemdUnitFileList>(dbusreply.arguments().at(0));
@@ -138,14 +137,12 @@ bool SystemdCommunicator::serviceExists()
     {
         if (unitFile.path.contains(m_serviceName + ".service"))
         {
-            m_error = "Success";
-            emit errorChanged();
+            setError("Success");
             return true;
         }
     }
 
-    m_error = "Service " + m_serviceName + " doesn't exist";
-    emit errorChanged();
+    setError("Service " + m_serviceName + " doesn't exist");
     qDebug() << "Service does not exist!";
     return false;
 }

+ 2 - 2
lib/src/temp.cpp

@@ -50,7 +50,7 @@ Temp::Temp(Hwmon *parent, uint index) :
             m_value /= 1000;
         }
         else
-            qDebug() << "Can't open valueFile " << parent->path() + "/temp" + QString::number(index) + "_input";
+            qCritical() << "Can't open valueFile " << parent->path() + "/temp" + QString::number(index) + "_input";
 
         if (labelFile.open(QFile::ReadOnly))
             m_label = QTextStream(&labelFile).readLine();
@@ -108,7 +108,7 @@ void Temp::reset()
             m_value /= 1000;
         }
         else
-            qDebug() << "Can't open valueFile " << m_parent->path() + "/temp" + QString::number(m_index) + "_input";
+            qCritical() << "Can't open valueFile " << m_parent->path() + "/temp" + QString::number(m_index) + "_input";
     }
 }