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

refactor(avform): Changed combobox index checks on asserts

This commit is contained in:
Diadlo 2016-08-25 22:48:22 +03:00
parent 9478377868
commit ef70b20a2b
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -34,6 +34,7 @@
#include <QDebug>
#include <QScreen>
#include <QShowEvent>
#include <cassert>
#include <map>
@ -147,17 +148,10 @@ void AVForm::rescanDevices()
void AVForm::on_videoModescomboBox_currentIndexChanged(int index)
{
if (index < 0 || index >= videoModes.size())
{
qWarning() << "Invalid mode index:" << index;
return;
}
assert(0 <= index && index < videoModes.size());
int devIndex = videoDevCombobox->currentIndex();
if (devIndex < 0 || devIndex >= videoDeviceList.size())
{
qWarning() << "Invalid device index:" << devIndex;
return;
}
assert(0 <= devIndex && devIndex < videoDeviceList.size());
QString devName = videoDeviceList[devIndex].first;
VideoMode mode = videoModes[index];
@ -409,11 +403,7 @@ void AVForm::updateVideoModes(int curIndex)
void AVForm::on_videoDevCombobox_currentIndexChanged(int index)
{
if (index < 0 || index >= videoDeviceList.size())
{
qWarning() << "Invalid index:" << index;
return;
}
assert(0 <= index && index < videoDeviceList.size());
Settings::getInstance().setScreenGrabbed(false);
QString dev = videoDeviceList[index].first;
@ -555,6 +545,7 @@ void AVForm::createVideoSurface()
{
if (camVideoSurface)
return;
camVideoSurface = new VideoSurface(QPixmap(), CamFrame);
camVideoSurface->setObjectName(QStringLiteral("CamVideoSurface"));
camVideoSurface->setMinimumSize(QSize(160, 120));
@ -566,6 +557,7 @@ void AVForm::killVideoSurface()
{
if (!camVideoSurface)
return;
QLayoutItem *child;
while ((child = gridLayout->takeAt(0)) != 0)
delete child;