Skip to content
Snippets Groups Projects
Commit 918100d5 authored by jpbl's avatar jpbl
Browse files

fixed the lock problem

parent 7c9839ee
Branches
Tags
No related merge requests found
...@@ -106,6 +106,7 @@ PhoneLine::sendKey(Qt::Key c) ...@@ -106,6 +106,7 @@ PhoneLine::sendKey(Qt::Key c)
break; break;
default: default:
if (QChar(c).isDigit()) {
if(!mCall) { if(!mCall) {
mSession.playDtmf(c); mSession.playDtmf(c);
mBuffer += QString(c).toStdString(); mBuffer += QString(c).toStdString();
...@@ -115,6 +116,7 @@ PhoneLine::sendKey(Qt::Key c) ...@@ -115,6 +116,7 @@ PhoneLine::sendKey(Qt::Key c)
} }
} }
} }
}
void void
PhoneLine::call() PhoneLine::call()
......
...@@ -41,13 +41,16 @@ PhoneLineManagerImpl::getNextAvailableLine() ...@@ -41,13 +41,16 @@ PhoneLineManagerImpl::getNextAvailableLine()
PhoneLine *selectedLine = NULL; PhoneLine *selectedLine = NULL;
QMutexLocker guard(&mPhoneLinesMutex); QMutexLocker guard(&mPhoneLinesMutex);
QMutexLocker guard2(&mCurrentLineMutex); mCurrentLineMutex.lock();
PhoneLine *current = mCurrentLine;
mCurrentLineMutex.unlock();
unsigned int i = 0; unsigned int i = 0;
while(i < mPhoneLines.size() && !selectedLine) { while(i < mPhoneLines.size() && !selectedLine) {
mPhoneLines[i]->lock(); mPhoneLines[i]->lock();
if(mPhoneLines[i]->isAvailable() && if(mPhoneLines[i]->isAvailable() &&
mPhoneLines[i] != mCurrentLine) { mPhoneLines[i] != current) {
selectedLine = mPhoneLines[i]; selectedLine = mPhoneLines[i];
} }
else { else {
...@@ -75,11 +78,9 @@ PhoneLineManagerImpl::selectNextAvailableLine() ...@@ -75,11 +78,9 @@ PhoneLineManagerImpl::selectNextAvailableLine()
mCurrentLine = selectedLine; mCurrentLine = selectedLine;
// select current line. // select current line.
{ // We don't need to lock it, since it is
PhoneLineLocker guard(mCurrentLine); // done at the top.
mCurrentLine->select(); selectedLine->select();
}
} }
return selectedLine; return selectedLine;
......
...@@ -6,7 +6,7 @@ TEMPLATE = app ...@@ -6,7 +6,7 @@ TEMPLATE = app
TARGET += TARGET +=
DEPENDPATH += . DEPENDPATH += .
INCLUDEPATH += . INCLUDEPATH += .
#CONFIG += debug CONFIG += debug
# Input # Input
HEADERS += Account.hpp \ HEADERS += Account.hpp \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment