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

fix closing video device after changing tab

This commit is contained in:
agilob 2015-10-10 14:26:35 +01:00
parent 0e9cfd948e
commit 83bcf2b8ae
No known key found for this signature in database
GPG Key ID: 296F0B764741106C

View File

@ -211,7 +211,7 @@ void AVForm::onVideoDevChanged(int index)
QSize savedRes = Settings::getInstance().getCamVideoRes();
int savedResIndex = -1;
bodyUI->videoModescomboBox->clear();
bodyUI->videoModescomboBox->blockSignals(true);
bodyUI->videoModescomboBox->blockSignals(true);
for (int i=0; i<res.size(); ++i)
{
QSize& r = res[i];
@ -266,37 +266,37 @@ void AVForm::getVideoDevices()
void AVForm::getAudioInDevices()
{
QString settingsInDev = Settings::getInstance().getInDev();
int inDevIndex = 0;
int inDevIndex = 0;
bodyUI->inDevCombobox->clear();
const ALchar *pDeviceList = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
if (pDeviceList)
{
//prevent currentIndexChanged to be fired while adding items
bodyUI->inDevCombobox->blockSignals(true);
//prevent currentIndexChanged to be fired while adding items
bodyUI->inDevCombobox->blockSignals(true);
while (*pDeviceList)
{
int len = strlen(pDeviceList);
#ifdef Q_OS_WIN
QString inDev = QString::fromUtf8(pDeviceList,len);
#else
QString inDev = QString::fromLocal8Bit(pDeviceList,len);
QString inDev = QString::fromLocal8Bit(pDeviceList,len);
#endif
bodyUI->inDevCombobox->addItem(inDev);
if (settingsInDev == inDev)
inDevIndex = bodyUI->inDevCombobox->count()-1;
inDevIndex = bodyUI->inDevCombobox->count()-1;
pDeviceList += len+1;
}
//addItem changes currentIndex -> reset
bodyUI->inDevCombobox->setCurrentIndex(-1);
bodyUI->inDevCombobox->blockSignals(false);
//addItem changes currentIndex -> reset
bodyUI->inDevCombobox->setCurrentIndex(-1);
bodyUI->inDevCombobox->blockSignals(false);
}
bodyUI->inDevCombobox->setCurrentIndex(inDevIndex);
bodyUI->inDevCombobox->setCurrentIndex(inDevIndex);
}
void AVForm::getAudioOutDevices()
{
QString settingsOutDev = Settings::getInstance().getOutDev();
int outDevIndex = 0;
int outDevIndex = 0;
bodyUI->outDevCombobox->clear();
const ALchar *pDeviceList;
if (alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE)
@ -305,15 +305,15 @@ void AVForm::getAudioOutDevices()
pDeviceList = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
if (pDeviceList)
{
//prevent currentIndexChanged to be fired while adding items
bodyUI->outDevCombobox->blockSignals(true);
//prevent currentIndexChanged to be fired while adding items
bodyUI->outDevCombobox->blockSignals(true);
while (*pDeviceList)
{
int len = strlen(pDeviceList);
#ifdef Q_OS_WIN
QString outDev = QString::fromUtf8(pDeviceList,len);
#else
QString outDev = QString::fromLocal8Bit(pDeviceList,len);
QString outDev = QString::fromLocal8Bit(pDeviceList,len);
#endif
bodyUI->outDevCombobox->addItem(outDev);
if (settingsOutDev == outDev)
@ -322,11 +322,11 @@ void AVForm::getAudioOutDevices()
}
pDeviceList += len+1;
}
//addItem changes currentIndex -> reset
bodyUI->outDevCombobox->setCurrentIndex(-1);
bodyUI->outDevCombobox->blockSignals(false);
//addItem changes currentIndex -> reset
bodyUI->outDevCombobox->setCurrentIndex(-1);
bodyUI->outDevCombobox->blockSignals(false);
}
bodyUI->outDevCombobox->setCurrentIndex(outDevIndex);
bodyUI->outDevCombobox->setCurrentIndex(outDevIndex);
}
void AVForm::onInDevChanged(const QString &deviceDescriptor)
@ -388,6 +388,7 @@ void AVForm::killVideoSurface()
while ((child = bodyUI->gridLayout->takeAt(0)) != 0)
delete child;
camVideoSurface->close();
delete camVideoSurface;
camVideoSurface = nullptr;
}