[libcalamares] Avoid some undesirable overloads
Implicit int -> bool had a comment, which suggests it should just be deleted from the overload set to avoid possible confusion.
This commit is contained in:
parent
8a14ddc97c
commit
461f011521
@ -104,6 +104,8 @@ public:
|
|||||||
/** @brief empty command-list with timeout to apply to entries. */
|
/** @brief empty command-list with timeout to apply to entries. */
|
||||||
CommandList( bool doChroot = true, std::chrono::seconds timeout = std::chrono::seconds( 10 ) );
|
CommandList( bool doChroot = true, std::chrono::seconds timeout = std::chrono::seconds( 10 ) );
|
||||||
CommandList( const QVariant& v, bool doChroot = true, std::chrono::seconds timeout = std::chrono::seconds( 10 ) );
|
CommandList( const QVariant& v, bool doChroot = true, std::chrono::seconds timeout = std::chrono::seconds( 10 ) );
|
||||||
|
CommandList( int ) = delete;
|
||||||
|
CommandList( const QVariant&, int ) = delete;
|
||||||
|
|
||||||
bool doChroot() const { return m_doChroot; }
|
bool doChroot() const { return m_doChroot; }
|
||||||
std::chrono::seconds defaultTimeout() const { return m_timeout; }
|
std::chrono::seconds defaultTimeout() const { return m_timeout; }
|
||||||
|
@ -364,8 +364,14 @@ commands:
|
|||||||
QCOMPARE( m[ "commands" ].toList().count(), 4 );
|
QCOMPARE( m[ "commands" ].toList().count(), 4 );
|
||||||
|
|
||||||
{
|
{
|
||||||
// Take care! The second parameter is a bool, so "3" here means "true"
|
#ifdef THIS_DOES_NOT_COMPILE_AND_THATS_THE_POINT
|
||||||
|
// Take care! The second parameter is a bool, so "3" here would
|
||||||
|
// mean "true", except the int overload is deleted to prevent just that.
|
||||||
Calamares::CommandList cmds( m[ "commands" ], 3 );
|
Calamares::CommandList cmds( m[ "commands" ], 3 );
|
||||||
|
// .. and there's no conversion from std::chrono::duration to bool either.
|
||||||
|
Calamares::CommandList cmds( m[ "commands" ], std::chrono::seconds( 3 ) );
|
||||||
|
#endif
|
||||||
|
Calamares::CommandList cmds( m[ "commands" ], true );
|
||||||
QCOMPARE( cmds.defaultTimeout(), std::chrono::seconds( 10 ) );
|
QCOMPARE( cmds.defaultTimeout(), std::chrono::seconds( 10 ) );
|
||||||
// But the 4 commands are there anyway
|
// But the 4 commands are there anyway
|
||||||
QCOMPARE( cmds.count(), 4 );
|
QCOMPARE( cmds.count(), 4 );
|
||||||
|
Loading…
Reference in New Issue
Block a user