Skip to content

Commit

Permalink
assertions weakened to warnings to prevent property inspectors ( f.e …
Browse files Browse the repository at this point in the history
…gammaray ), that do not know about the specific semantics of the gradient direction, from crashing
  • Loading branch information
uwerat committed Oct 9, 2024
1 parent 920f7e2 commit d6b9ea4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/common/QskGradient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,10 +615,11 @@ void QskGradient::setLinearDirection( const QskLinearDirection& direction )

QskLinearDirection QskGradient::linearDirection() const
{
Q_ASSERT( m_type == Linear );

if ( m_type != Linear )
{
qWarning() << "Requesting linear attributes from a non linear gradient.";
return QskLinearDirection( 0.0, 0.0, 0.0, 0.0 );
}

return QskLinearDirection( m_values[0], m_values[1], m_values[2], m_values[3] );
}
Expand All @@ -644,10 +645,11 @@ void QskGradient::setRadialDirection( const QskRadialDirection& direction )

QskRadialDirection QskGradient::radialDirection() const
{
Q_ASSERT( m_type == Radial );

if ( m_type != Radial )
{
qWarning() << "Requesting radial attributes from a non radial gradient.";
return QskRadialDirection( 0.5, 0.5, 0.0 );
}

return QskRadialDirection( m_values[0], m_values[1], m_values[2], m_values[3] );
}
Expand Down Expand Up @@ -683,10 +685,11 @@ void QskGradient::setConicDirection( const QskConicDirection& direction )

QskConicDirection QskGradient::conicDirection() const
{
Q_ASSERT( m_type == Conic );

if ( m_type != Conic )
{
qWarning() << "Requesting conic attributes from a non conic gradient.";
return QskConicDirection( 0.5, 0.5, 0.0, 0.0 );
}

QskConicDirection dir( m_values[0], m_values[1], m_values[2], m_values[3] );
dir.setAspectRatio( m_values[4] );
Expand Down
2 changes: 0 additions & 2 deletions src/common/QskGradientDirection.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <qpoint.h>
#include <qline.h>

class QLineF;

class QSK_EXPORT QskLinearDirection
{
Q_GADGET
Expand Down

0 comments on commit d6b9ea4

Please sign in to comment.