mirror of
https://github.com/parchlinux/calamares.git
synced 2025-02-24 10:55:46 -05:00
[libcalamares] Remove cBoolSetter
This class was used only once, and is confusing because the assignment happens always, but to the opposite value as what was visible. It can be replaced with other scoped assignment, instead. Removes the tests for it, too.
This commit is contained in:
parent
b0149c2712
commit
bba5b21873
3 changed files with 4 additions and 41 deletions
|
@ -42,20 +42,6 @@ struct cqDeleter
|
|||
}
|
||||
};
|
||||
|
||||
/// @brief Sets a bool to @p value and resets to !value on destruction
|
||||
template < bool value >
|
||||
struct cBoolSetter
|
||||
{
|
||||
bool& m_b;
|
||||
|
||||
cBoolSetter( bool& b )
|
||||
: m_b( b )
|
||||
{
|
||||
m_b = value;
|
||||
}
|
||||
~cBoolSetter() { m_b = !value; }
|
||||
};
|
||||
|
||||
/// @brief Blocks signals on a QObject until destruction
|
||||
using cSignalBlocker = QSignalBlocker;
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@ private Q_SLOTS:
|
|||
void testOddSizedPrintable();
|
||||
|
||||
/** @section Tests the RAII bits. */
|
||||
void testBoolSetter();
|
||||
void testPointerSetter();
|
||||
|
||||
/** @section Tests the Traits bits. */
|
||||
|
@ -340,28 +339,6 @@ LibCalamaresTests::testOddSizedPrintable()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
LibCalamaresTests::testBoolSetter()
|
||||
{
|
||||
bool b = false;
|
||||
|
||||
QVERIFY( !b );
|
||||
{
|
||||
QVERIFY( !b );
|
||||
cBoolSetter< true > x( b );
|
||||
QVERIFY( b );
|
||||
}
|
||||
QVERIFY( !b );
|
||||
|
||||
QVERIFY( !b );
|
||||
{
|
||||
QVERIFY( !b );
|
||||
cBoolSetter< false > x( b );
|
||||
QVERIFY( !b ); // Still!
|
||||
}
|
||||
QVERIFY( b );
|
||||
}
|
||||
|
||||
void
|
||||
LibCalamaresTests::testPointerSetter()
|
||||
{
|
||||
|
@ -384,7 +361,7 @@ LibCalamaresTests::testPointerSetter()
|
|||
}
|
||||
QCOMPARE( special, 3 );
|
||||
{
|
||||
cPointerSetter<int> p( nullptr );
|
||||
cPointerSetter< int > p( nullptr );
|
||||
}
|
||||
QCOMPARE( special, 3 );
|
||||
{
|
||||
|
@ -490,8 +467,7 @@ LibCalamaresTests::testVariantStringListCode()
|
|||
QStringList { "astring" } ); // A single string **can** be considered a stringlist!
|
||||
m.insert( key, QString( "more strings" ) );
|
||||
QCOMPARE( getStringList( m, key ).count(), 1 );
|
||||
QCOMPARE( getStringList( m, key ),
|
||||
QStringList { "more strings" } );
|
||||
QCOMPARE( getStringList( m, key ), QStringList { "more strings" } );
|
||||
m.insert( key, QString() );
|
||||
QCOMPARE( getStringList( m, key ).count(), 1 );
|
||||
QCOMPARE( getStringList( m, key ), QStringList { QString() } );
|
||||
|
|
|
@ -174,7 +174,8 @@ LocalePage::locationChanged( const CalamaresUtils::Locale::TimeZoneData* locatio
|
|||
{
|
||||
return;
|
||||
}
|
||||
cBoolSetter< true > b( m_blockTzWidgetSet );
|
||||
m_blockTzWidgetSet = true; // Blocked until we go out of scope
|
||||
cPointerSetter b( &m_blockTzWidgetSet, false );
|
||||
|
||||
// Set region index
|
||||
int index = m_regionCombo->findData( location->region() );
|
||||
|
|
Loading…
Add table
Reference in a new issue