[libcalamaresui] Use meaningful asserts

- In debug mode, hitting assert(false) is meaningless,
 - In release mode, the assert is optimized out.
 - So assert the condition we're actually testing, for better messages.
This commit is contained in:
Adriaan de Groot 2019-05-27 15:38:37 +02:00
parent 976ad7e3e7
commit f64e55f0dc

View File

@ -61,9 +61,9 @@ ImageRegistry::cacheKey( const QSize& size, float opacity, QColor tint )
QPixmap QPixmap
ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, QColor tint ) ImageRegistry::pixmap( const QString& image, const QSize& size, CalamaresUtils::ImageMode mode, float opacity, QColor tint )
{ {
Q_ASSERT( !(size.width() < 0 || size.height() < 0) );
if ( size.width() < 0 || size.height() < 0 ) if ( size.width() < 0 || size.height() < 0 )
{ {
Q_ASSERT( false );
return QPixmap(); return QPixmap();
} }
@ -159,15 +159,9 @@ ImageRegistry::putInCache( const QString& image, const QSize& size, CalamaresUti
if ( s_cache.contains( image ) ) if ( s_cache.contains( image ) )
{ {
subcache = s_cache.value( image ); subcache = s_cache.value( image );
if ( subcache.contains( mode ) ) if ( subcache.contains( mode ) )
{ {
subsubcache = subcache.value( mode ); subsubcache = subcache.value( mode );
/* if ( subsubcache.contains( size.width() * size.height() ) )
{
Q_ASSERT( false );
}*/
} }
} }