1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor: Remove extra checks in [un]subscribe

This commit is contained in:
Diadlo 2017-06-26 13:53:52 +03:00
parent a22694c9e8
commit 60dc4b34a4
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -210,10 +210,7 @@ void CameraSource::subscribe()
{
QWriteLocker locker{&streamMutex};
if (_isNone) {
++subscriptions;
}
++subscriptions;
openDevice();
}
@ -221,22 +218,10 @@ void CameraSource::unsubscribe()
{
QWriteLocker locker{&streamMutex};
if (_isNone) {
--subscriptions;
return;
}
if (!device) {
qWarning() << "Unsubscribing with zero subscriber";
return;
}
if (subscriptions - 1 == 0) {
--subscriptions;
if (subscriptions == 0) {
closeDevice();
} else {
device->close();
}
subscriptions--;
}
/**