Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-92908

gradients widget example crashes

    XMLWordPrintable

Details

    • 76537c065aea1cb3926796f6a34eb39eb81f605f (qt/qtbase/dev) 905c71a434ae6de2cc075e00da2149065f7b5f98 (qt/qtbase/6.1)

    Description

      Initially m_hoverPoints has 0,0 and 0,-0. So this generates a NaN:

      uint ShadeWidget::colorAt(int x)
      {
          generateShade();
      
          QPolygonF pts = m_hoverPoints->points();
          for (int i = 1; i < pts.size(); ++i) {
              if (pts.at(i - 1).x() <= x && pts.at(i).x() >= x) {
                  QLineF l(pts.at(i - 1), pts.at(i));
                  l.setLength(l.length() * ((x - l.x1()) / l.dx())); // dx is 0, I think?
                  return m_shade.pixel(qRound(qMin(l.x2(), (qreal(m_shade.width() - 1)))),
                                       qRound(qMin(l.y2(), qreal(m_shade.height() - 1))));
              }
          }
          return 0;
      }
      

      and after https://codereview.qt-project.org/c/qt/qtbase/+/324688 we are checking for that in QLineF::setLength().

      	Locals		
      		i	1	int
      		l	@0x7fffffffc9b0	QLineF
      			pt1	(0.0, 0.0)	QPointF
      			pt2	(0.0, -0.0)	QPointF
      		pts	<2 items>	QPolygonF
      			[0]	(0.0, 0.0)	QPointF
      			[1]	(0.0, -0.0)	QPointF
      		this	@0x5555558ec990	ShadeWidget
      			[QWidget]	@0x5555558ec990	QWidget
      			[d]	@0x555555a727f0	QWidgetPrivate
      			[parent]	@0x55555590fa40	GradientEditor
      			[children]	<1 items>	QList<QObject*>
      			[properties]	<at least 0 items>	
      			[methods]	<1 items>	
      			[extra]		
      			m_alpha_gradient	@0x5555558ec9e0	QLinearGradient
      			m_hoverPoints	@0x55555578a800	HoverPoints
      				[QObject]	@0x55555578a800	QObject
      				[d]	@0x555555945720	QObjectPrivate
      				[parent]	@0x5555558ec990	ShadeWidget
      				[children]	<0 items>	QList<QObject*>
      				[properties]	<at least 0 items>	
      				[methods]	<3 items>	
      				[extra]		
      				m_bounds	0.0x0.0+0.0+0.0	QRectF
      				m_connectionPen	@0x55555578a8a8	QPen
      				m_connectionType	HoverPoints::CurveConnection (2)	HoverPoints::ConnectionType
      				m_currentIndex	-1	int
      				m_editable	true	bool
      				m_enabled	true	bool
      				m_fingerPointMapping	<0 items>	QHash<int, int>
      				m_locks	<2 items>	QList<unsigned int>
      				m_pointBrush	@0x55555578a8a0	QBrush
      				m_pointPen	@0x55555578a898	QPen
      				m_pointSize	(11.0, 11.0)	QSizeF
      				m_points	<2 items>	QPolygonF
      					[0]	(0.0, 0.0)	QPointF
      					[1]	(0.0, -0.0)	QPointF
      				m_shape	HoverPoints::CircleShape (0)	HoverPoints::PointShape
      				m_sortType	HoverPoints::XSort (1)	HoverPoints::SortType
      				m_widget	@0x5555558ec990	ShadeWidget
      				staticMetaObject	@0x5555555a8fe0	QMetaObject
      			m_shade	(140x40)	QImage
      			m_shade_type	ShadeWidget::RedShade (0)	ShadeWidget::ShadeType
      			staticMetaObject	@0x5555555a9160	QMetaObject
      		x	0	int
      	Inspector		
      	Expressions		
      	Return Value		
      	Tooltip		
      		m_shade	(140x40)	QImage
      
      1  raise                                                                           
      2  abort                                                                           
      3  qt_message_fatal                                      qlogging.cpp         1892 
      4  QMessageLogger::fatal                                 qlogging.cpp         890  
      5  qt_assert                                             qglobal.cpp          3114 
      6  QLineF::setLength                                     qline.h              375  
      7  ShadeWidget::colorAt                                  gradients.cpp        108  
      8  GradientEditor::pointsUpdated                         gradients.cpp        229  
      9  QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPr qobjectdefs_impl.h   152  
      10 QtPrivate::FunctionPointer<void (GradientEditor:: *)( qobjectdefs_impl.h   185  
      11 QtPrivate::QSlotObject<void (GradientEditor:: *)(), Q qobjectdefs_impl.h   395  
      12 QtPrivate::QSlotObjectBase::call                      qobjectdefs_impl.h   375  
      13 doActivate<false>                                     qobject.cpp          3822 
      14 QMetaObject::activate                                 qobject.cpp          3882 
      15 ShadeWidget::colorsChanged                            moc_gradients.cpp    135  
      16 QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPr qobjectdefs_impl.h   152  
      17 QtPrivate::FunctionPointer<void (ShadeWidget:: *)()>: qobjectdefs_impl.h   185  
      18 QtPrivate::QSlotObject<void (ShadeWidget:: *)(), QtPr qobjectdefs_impl.h   395  
      19 QtPrivate::QSlotObjectBase::call                      qobjectdefs_impl.h   375  
      20 doActivate<false>                                     qobject.cpp          3822 
      21 QMetaObject::activate                                 qobject.cpp          3882 
      22 HoverPoints::pointsChanged                            moc_hoverpoints.cpp  151  
      23 HoverPoints::firePointChange                          hoverpoints.cpp      423  
      24 HoverPoints::eventFilter                              hoverpoints.cpp      262  
      25 QCoreApplicationPrivate::sendThroughObjectEventFilter qcoreapplication.cpp 1165 
      26 QApplicationPrivate::notify_helper                    qapplication.cpp     3389 
      27 QApplication::notify                                  qapplication.cpp     3345 
      28 QCoreApplication::notifyInternal2                     qcoreapplication.cpp 1039 
      29 QCoreApplication::sendEvent                           qcoreapplication.cpp 1447 
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes