1 Commits

Author SHA1 Message Date
Robin "Rogo" Goltermann
d7e1741833 possible fix for memory leak 2022-07-20 15:43:45 +02:00
2 changed files with 6 additions and 8 deletions

View File

@@ -63,11 +63,9 @@ void MainWindow::sendCommand(QString cmd)
void MainWindow::replyFinished(QNetworkReply* reply) void MainWindow::replyFinished(QNetworkReply* reply)
{ {
QString ans;
if(reply->error() == QNetworkReply::NoError) { if(reply->error() == QNetworkReply::NoError) {
QByteArray data = reply->readAll(); QByteArray data = reply->readAll();
ans = QString(data); mAnswer = QString(data);
} else { } else {
qDebug() << reply->url(); qDebug() << reply->url();
qDebug() << reply->errorString(); qDebug() << reply->errorString();
@@ -77,7 +75,7 @@ void MainWindow::replyFinished(QNetworkReply* reply)
// check power state // check power state
QRegularExpression regexPower("<Power_Control><Power>(.+)</Power></Power_Control>"); QRegularExpression regexPower("<Power_Control><Power>(.+)</Power></Power_Control>");
QRegularExpressionMatch matchPower = regexPower.match(ans); QRegularExpressionMatch matchPower = regexPower.match(mAnswer);
if (matchPower.hasMatch()) { if (matchPower.hasMatch()) {
if (matchPower.captured(1) == "On") mPowered = true; if (matchPower.captured(1) == "On") mPowered = true;
else if (matchPower.captured(1) == "Off") mPowered = false; else if (matchPower.captured(1) == "Off") mPowered = false;
@@ -85,14 +83,14 @@ void MainWindow::replyFinished(QNetworkReply* reply)
// check volume // check volume
QRegularExpression regexVolume("<Volume><Lvl><Val>(.+)</Val>"); QRegularExpression regexVolume("<Volume><Lvl><Val>(.+)</Val>");
QRegularExpressionMatch matchVolume = regexVolume.match(ans); QRegularExpressionMatch matchVolume = regexVolume.match(mAnswer);
if (matchVolume.hasMatch()) { if (matchVolume.hasMatch()) {
mVolume = matchVolume.captured(1).toInt(); mVolume = matchVolume.captured(1).toInt();
} }
// check input // check input
QRegularExpression regexInput("<Input><Input_Sel>(.+)</Input_Sel>"); QRegularExpression regexInput("<Input><Input_Sel>(.+)</Input_Sel>");
QRegularExpressionMatch matchInput = regexInput.match(ans); QRegularExpressionMatch matchInput = regexInput.match(mAnswer);
if (matchInput.hasMatch()) if (matchInput.hasMatch())
mInput = matchInput.captured(1); mInput = matchInput.captured(1);
@@ -225,7 +223,6 @@ void MainWindow::on_btn_spotify_clicked()
void MainWindow::on_btn_airplay_clicked() void MainWindow::on_btn_airplay_clicked()
{ {
// TODO
sendCommand("<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Input><Input_Sel>IPOD</Input_Sel></Input></Main_Zone></YAMAHA_AV>"); sendCommand("<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Input><Input_Sel>IPOD</Input_Sel></Input></Main_Zone></YAMAHA_AV>");
mInput = "IPOD"; mInput = "IPOD";
} }

View File

@@ -45,13 +45,14 @@ private:
const int TIME_VOL_COLLECT = 400; const int TIME_VOL_COLLECT = 400;
const int TIME_UPDATE_STATE = 10000; const int TIME_UPDATE_STATE = 10000;
const int TIME_UPDATE_ADDRESS = 1000; const int TIME_UPDATE_ADDRESS = 1000;
QString mAddress; QString mAddress;
QTimer mTimerValCollect; QTimer mTimerValCollect;
QTimer mTimerUpdateState; QTimer mTimerUpdateState;
QTimer mTimerUpdateAddress; QTimer mTimerUpdateAddress;
QSettings* mSettings = nullptr; QSettings* mSettings = nullptr;
QNetworkAccessManager *mNetworkManager = nullptr; QNetworkAccessManager *mNetworkManager = nullptr;
QString mAnswer;
void sendCommand(QString cmd); void sendCommand(QString cmd);
void updateUi(); void updateUi();