Skip to content

Commit

Permalink
tidy: Explicitly convert boolean<->int when r/w QDomElement attributes.
Browse files Browse the repository at this point in the history
The clang-tidy "implicit boolean conversion" check pointed out a
couple of places where booleans were being implicitly converted to
integers when setting attributes on a QDomElement, or implicitly being
converted to boolean when reading attributes from a QDomELement.  Be
explicit about these conversion.

https://clang.llvm.org/extra/clang-tidy/checks/readability-implicit-bool-conversion.html
  • Loading branch information
linuxdude42 committed Mar 26, 2019
1 parent a3ffc24 commit 342fab6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions mythplugins/mytharchive/mytharchive/exportnative.cpp
Expand Up @@ -403,11 +403,11 @@ void ExportNative::createConfigFile(const QString &filename)

// add the options to the xml file
QDomElement options = doc.createElement("options");
options.setAttribute("createiso", m_bCreateISO);
options.setAttribute("doburn", m_bDoBurn);
options.setAttribute("createiso", static_cast<int>(m_bCreateISO));
options.setAttribute("doburn", static_cast<int>(m_bDoBurn));
options.setAttribute("mediatype", m_archiveDestination.type);
options.setAttribute("dvdrsize", (qint64)m_archiveDestination.freeSpace);
options.setAttribute("erasedvdrw", m_bEraseDvdRw);
options.setAttribute("erasedvdrw", static_cast<int>(m_bEraseDvdRw));
options.setAttribute("savedirectory", m_saveFilename);
job.appendChild(options);

Expand Down
8 changes: 4 additions & 4 deletions mythplugins/mytharchive/mytharchive/mythburn.cpp
Expand Up @@ -588,7 +588,7 @@ void MythBurn::createConfigFile(const QString &filename)

QDomElement file = doc.createElement("file");
file.setAttribute("type", a->type.toLower() );
file.setAttribute("usecutlist", a->useCutlist);
file.setAttribute("usecutlist", static_cast<int>(a->useCutlist));
file.setAttribute("filename", a->filename);
file.setAttribute("encodingprofile", a->encoderProfile->name);
if (a->editedDetails)
Expand Down Expand Up @@ -624,11 +624,11 @@ void MythBurn::createConfigFile(const QString &filename)

// add the options to the xml file
QDomElement options = doc.createElement("options");
options.setAttribute("createiso", m_bCreateISO);
options.setAttribute("doburn", m_bDoBurn);
options.setAttribute("createiso", static_cast<int>(m_bCreateISO));
options.setAttribute("doburn", static_cast<int>(m_bDoBurn));
options.setAttribute("mediatype", m_archiveDestination.type);
options.setAttribute("dvdrsize", (qint64)m_archiveDestination.freeSpace);
options.setAttribute("erasedvdrw", m_bEraseDvdRw);
options.setAttribute("erasedvdrw", static_cast<int>(m_bEraseDvdRw));
options.setAttribute("savefilename", m_saveFilename);
job.appendChild(options);

Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythupnp/wsdl.cpp
Expand Up @@ -399,7 +399,7 @@ QDomElement Wsdl::CreateMethodType( MethodInfo &oInfo,

oNode.setAttribute( "minOccurs", 0 );
oNode.setAttribute( "name" , sTypeName + "Result" );
oNode.setAttribute( "nillable" , true ); //-=>TODO: This may need to be determined by sParamType
oNode.setAttribute( "nillable" , static_cast<int>(true) ); //-=>TODO: This may need to be determined by sParamType

bool bCustomType = IsCustomType( sType );

Expand Down Expand Up @@ -445,7 +445,7 @@ QDomElement Wsdl::CreateMethodType( MethodInfo &oInfo,

oNode.setAttribute( "minOccurs", 0 );
oNode.setAttribute( "name" , sName );
oNode.setAttribute( "nillable" , true ); //-=>TODO: This may need to be determined by sParamType
oNode.setAttribute( "nillable" , static_cast<int>(true) ); //-=>TODO: This may need to be determined by sParamType
oNode.setAttribute( "type" , sPrefix + sParamType );

oSeqNode.appendChild( oNode );
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythupnp/xsd.cpp
Expand Up @@ -433,7 +433,7 @@ bool Xsd::RenderXSD( HTTPRequest *pRequest, QObject *pClass )
QString sNewPropName( metaProperty.name() );

if (IsNillable( sType ))
oNode.setAttribute( "nillable" , true );
oNode.setAttribute( "nillable" , static_cast<int>(true) );

if (bCustomType)
{
Expand Down
10 changes: 5 additions & 5 deletions mythtv/programs/mythbackend/httpstatus.cpp
Expand Up @@ -211,8 +211,8 @@ void HttpStatus::FillStatusXML( QDomDocument *pDoc )
encoders.appendChild(encoder);

encoder.setAttribute("id" , elink->GetInputID() );
encoder.setAttribute("local" , isLocal );
encoder.setAttribute("connected" , elink->IsConnected() );
encoder.setAttribute("local" , static_cast<int>(isLocal));
encoder.setAttribute("connected" , static_cast<int>(elink->IsConnected()));
encoder.setAttribute("state" , state );
encoder.setAttribute("sleepstatus" , elink->GetSleepStatus() );
//encoder.setAttribute("lowOnFreeSpace", elink->isLowOnFreeSpace());
Expand Down Expand Up @@ -725,9 +725,9 @@ int HttpStatus::PrintEncoderStatus( QTextStream &os, QDomElement encoders )
? "local" : "remote";
QString sCardId = e.attribute( "id" , "0" );
QString sHostName = e.attribute( "hostname" , "Unknown");
bool bConnected= e.attribute( "connected", "0" ).toInt();
bool bConnected= static_cast<bool>(e.attribute( "connected", "0" ).toInt());

bool bIsLowOnFreeSpace=e.attribute( "lowOnFreeSpace", "0").toInt();
bool bIsLowOnFreeSpace=static_cast<bool>(e.attribute( "lowOnFreeSpace", "0").toInt());

QString sDevlabel = e.attribute( "devlabel", "[ UNKNOWN ]");

Expand Down Expand Up @@ -1512,7 +1512,7 @@ void HttpStatus::FillProgramInfo(QDomDocument *pDoc,
program.setAttribute( "subTitle" , pInfo->GetSubtitle());
program.setAttribute( "category" , pInfo->GetCategory());
program.setAttribute( "catType" , pInfo->GetCategoryTypeString());
program.setAttribute( "repeat" , pInfo->IsRepeat() );
program.setAttribute( "repeat" , static_cast<int>(pInfo->IsRepeat()));

if (bDetails)
{
Expand Down

0 comments on commit 342fab6

Please sign in to comment.