Message ID | 20240109131244.10357-1-tumic@gpxsee.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Fixed qv4l2 crash with drivers that implement VIDIOC_ENUM_FRAMESIZES for outputs | expand |
On 09/01/2024 14:12, tumic@gpxsee.org wrote: > From: Martin Tůma <martin.tuma@digiteqautomotive.com> > > When a v4l2 driver implements VIDIOC_ENUM_FRAMESIZES for an output, qv4l2 > crashes on accessing the "frame size widget" that does not exist. This patch > adds a proper check for the widget not being NULL. Thank you, I've just merged this patch. Regards, Hans > > Signed-off-by: Martin Tůma <martin.tuma@digiteqautomotive.com> > --- > utils/qv4l2/general-tab.cpp | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > > diff --git a/utils/qv4l2/general-tab.cpp b/utils/qv4l2/general-tab.cpp > index ffa44eca..bceaab09 100644 > --- a/utils/qv4l2/general-tab.cpp > +++ b/utils/qv4l2/general-tab.cpp > @@ -2165,13 +2165,16 @@ void GeneralTab::updateFrameSize() > > ok = !enum_framesizes(frmsize, m_pixelformat); > if (ok && frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) { > - do { > - m_frameSize->addItem(QString("%1x%2") > - .arg(frmsize.discrete.width).arg(frmsize.discrete.height)); > - if (frmsize.discrete.width == m_width && > - frmsize.discrete.height == m_height) > - m_frameSize->setCurrentIndex(frmsize.index); > - } while (!enum_framesizes(frmsize)); > + if (m_frameSize) { > + do { > + m_frameSize->addItem(QString("%1x%2") > + .arg(frmsize.discrete.width) > + .arg(frmsize.discrete.height)); > + if (frmsize.discrete.width == m_width && > + frmsize.discrete.height == m_height) > + m_frameSize->setCurrentIndex(frmsize.index); > + } while (!enum_framesizes(frmsize)); > + } > > m_discreteSizes = true; > m_frameWidth->setEnabled(false); > @@ -2187,7 +2190,8 @@ void GeneralTab::updateFrameSize() > m_frameHeight->setMaximum(m_height); > m_frameHeight->setValue(m_height); > m_frameHeight->blockSignals(false); > - m_frameSize->setEnabled(!m_haveBuffers); > + if (m_frameSize) > + m_frameSize->setEnabled(!m_haveBuffers); > updateFrameInterval(); > return; > }
diff --git a/utils/qv4l2/general-tab.cpp b/utils/qv4l2/general-tab.cpp index ffa44eca..bceaab09 100644 --- a/utils/qv4l2/general-tab.cpp +++ b/utils/qv4l2/general-tab.cpp @@ -2165,13 +2165,16 @@ void GeneralTab::updateFrameSize() ok = !enum_framesizes(frmsize, m_pixelformat); if (ok && frmsize.type == V4L2_FRMSIZE_TYPE_DISCRETE) { - do { - m_frameSize->addItem(QString("%1x%2") - .arg(frmsize.discrete.width).arg(frmsize.discrete.height)); - if (frmsize.discrete.width == m_width && - frmsize.discrete.height == m_height) - m_frameSize->setCurrentIndex(frmsize.index); - } while (!enum_framesizes(frmsize)); + if (m_frameSize) { + do { + m_frameSize->addItem(QString("%1x%2") + .arg(frmsize.discrete.width) + .arg(frmsize.discrete.height)); + if (frmsize.discrete.width == m_width && + frmsize.discrete.height == m_height) + m_frameSize->setCurrentIndex(frmsize.index); + } while (!enum_framesizes(frmsize)); + } m_discreteSizes = true; m_frameWidth->setEnabled(false); @@ -2187,7 +2190,8 @@ void GeneralTab::updateFrameSize() m_frameHeight->setMaximum(m_height); m_frameHeight->setValue(m_height); m_frameHeight->blockSignals(false); - m_frameSize->setEnabled(!m_haveBuffers); + if (m_frameSize) + m_frameSize->setEnabled(!m_haveBuffers); updateFrameInterval(); return; }