Update the detection of the arguments in Qt's invokeMethod.
invokeMethod can invoke functions by name (string) rather than a direct function call (i.e. reflection). The old code wasn't correctly parsing out the argument which contained the name of the function to call. This resulted in that function being reported as unused when it is.
This commit is contained in:
parent
61eb262244
commit
3d0524ecc6
|
@ -63,7 +63,7 @@
|
|||
|
||||
<!-- qt can call methods as strings using invokeMethod -->
|
||||
<reflection>
|
||||
<call arg="4">invokeMethod</call>
|
||||
<call arg="2">invokeMethod</call>
|
||||
</reflection>
|
||||
|
||||
<!-- the SLOT/SIGNAL methods can be cause false-positives for pure
|
||||
|
|
|
@ -170,9 +170,22 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
|
|||
if (settings->library.isreflection(tok->str())) {
|
||||
const int index = settings->library.reflectionArgument(tok->str());
|
||||
if (index >= 0) {
|
||||
const Token * funcToken = tok->tokAt(index);
|
||||
if (funcToken) {
|
||||
std::string value = funcToken->str();
|
||||
const Token * funcToken = tok->next();
|
||||
int p = 0;
|
||||
std::string value;
|
||||
while(funcToken) {
|
||||
if (funcToken->str()==",") {
|
||||
p++;
|
||||
if (p==index) {
|
||||
break;
|
||||
}
|
||||
value = "";
|
||||
} else {
|
||||
value += funcToken->str();
|
||||
}
|
||||
funcToken = funcToken->next();
|
||||
}
|
||||
if (p==index) {
|
||||
value = value.substr(1, value.length() - 2);
|
||||
_functions[value].usedOtherFile = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue