diff options
author | Georg Zotti <Georg.Zotti@univie.ac.at> | 2022-05-20 14:25:06 +0200 |
---|---|---|
committer | Georg Zotti <Georg.Zotti@univie.ac.at> | 2022-05-20 14:25:06 +0200 |
commit | d5619749ded4476e61744c832524af5616350312 (patch) | |
tree | e59d5bef5aedfc9ce2a8f4b75094298a4f44d57a | |
parent | 159ba32e8ab795107889a74893f226bffcc4dcff (diff) |
Fix a few more clazy warnings
-rw-r--r-- | src/gui/StelScriptSyntaxHighlighter.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/gui/StelScriptSyntaxHighlighter.cpp b/src/gui/StelScriptSyntaxHighlighter.cpp index 868e644519..5b27d4eb8d 100644 --- a/src/gui/StelScriptSyntaxHighlighter.cpp +++ b/src/gui/StelScriptSyntaxHighlighter.cpp @@ -34,13 +34,14 @@ void StelScriptSyntaxHighlighter::locateFunctions( const QMetaObject* metaObject, QString scriptName ) { QSet<QString> funcs; + static const QRegularExpression trimFuncExp("\\(.*$"); for( int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i ) { if( metaObject->method(i).methodType() == QMetaMethod::Slot && metaObject->method(i).access() == QMetaMethod::Public ) { QString fn = metaObject->method(i).methodSignature(); - fn.replace(QRegularExpression("\\(.*$"), ""); + fn.replace(trimFuncExp, ""); funcs << fn; } } @@ -54,7 +55,8 @@ StelScriptSyntaxHighlighter::StelScriptSyntaxHighlighter(QTextDocument *parent) // Highlight object names which can be used in scripting. StelModuleMgr* mmgr = &StelApp::getInstance().getModuleMgr(); - for( auto* m : mmgr->getAllModules() ) + const QList allModules = mmgr->getAllModules(); + for( auto* m : allModules ) { locateFunctions( m->metaObject(), m->objectName() ); } @@ -193,7 +195,7 @@ void StelScriptSyntaxHighlighter::setFormats(void) void StelScriptSyntaxHighlighter::highlightBlock(const QString &text) { // Function call: detect valid identifier with opening bracket. - QRegularExpression functionPat("\\b[A-Za-z_][A-Za-z0-9_]*\\s*\\("); + static const QRegularExpression functionPat("\\b[A-Za-z_][A-Za-z0-9_]*\\s*\\("); QRegularExpressionMatchIterator it = functionPat.globalMatch(text); while (it.hasNext()) { @@ -213,8 +215,8 @@ void StelScriptSyntaxHighlighter::highlightBlock(const QString &text) } // Finally, apply the Qt Example for a multiline comment block /*...*/ - QRegularExpression startExpression("/\\*"); - QRegularExpression endExpression("\\*/"); + static const QRegularExpression startExpression("/\\*"); + static const QRegularExpression endExpression("\\*/"); setCurrentBlockState(0); int startIndex = 0; |