Skip to content

Commit

Permalink
Make cppcheck happy and adopt some suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Apr 15, 2024
1 parent d3f2fea commit 55ea0d6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
22 changes: 11 additions & 11 deletions src/core/pluginmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,6 @@ void PluginManager::unloadPlugin( const QString &pluginPath )
}
}

const QString PluginManager::findProjectPlugin( const QString &projectPath ) const
{
QFileInfo fi( projectPath );
const QString pluginPath = QStringLiteral( "%1/%2.qml" ).arg( fi.absolutePath(), fi.completeBaseName() );
if ( QFileInfo::exists( pluginPath ) )
{
return pluginPath;
}
return QString();
}

void PluginManager::grantRequestedPluginPermission( bool permanent )
{
if ( permanent )
Expand All @@ -110,3 +99,14 @@ void PluginManager::denyRequestedPluginPermission( bool permanent )

mPermissionRequestPluginPath.clear();
}

QString PluginManager::findProjectPlugin( const QString &projectPath )
{
const QFileInfo fi( projectPath );
const QString pluginPath = QStringLiteral( "%1/%2.qml" ).arg( fi.absolutePath(), fi.completeBaseName() );
if ( QFileInfo::exists( pluginPath ) )
{
return pluginPath;
}
return QString();
}
8 changes: 4 additions & 4 deletions src/core/pluginmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ class PluginManager : public QObject
Q_OBJECT

public:
PluginManager( QQmlEngine *engine );
~PluginManager() = default;
explicit PluginManager( QQmlEngine *engine );
~PluginManager() override = default;

void loadPlugin( const QString &pluginPath, const QString &pluginName, bool skipPermissionCheck = false );
void unloadPlugin( const QString &pluginPath );

const QString findProjectPlugin( const QString &projectPath ) const;

Q_INVOKABLE void grantRequestedPluginPermission( bool permanent = false );
Q_INVOKABLE void denyRequestedPluginPermission( bool permanent = false );

static QString findProjectPlugin( const QString &projectPath );

signals:
void pluginPermissionRequested( const QString &pluginName );

Expand Down
6 changes: 3 additions & 3 deletions src/core/qgismobileapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ bool QgisMobileapp::loadProjectFile( const QString &path, const QString &name )

if ( !mProjectFilePath.isEmpty() )
{
mPluginManager->unloadPlugin( mPluginManager->findProjectPlugin( mProjectFilePath ) );
mPluginManager->unloadPlugin( PluginManager::findProjectPlugin( mProjectFilePath ) );
}
mAuthRequestHandler->clearStoredRealms();

Expand Down Expand Up @@ -1166,7 +1166,7 @@ void QgisMobileapp::readProjectFile()

connect( mMapCanvas, &QgsQuickMapCanvasMap::mapCanvasRefreshed, this, &QgisMobileapp::onMapCanvasRefreshed );

const QString projectPluginPath = mPluginManager->findProjectPlugin( mProjectFilePath );
const QString projectPluginPath = PluginManager::findProjectPlugin( mProjectFilePath );
if ( !projectPluginPath.isEmpty() )
{
mPluginManager->loadPlugin( projectPluginPath, tr( "Project Plugin" ) );
Expand Down Expand Up @@ -1393,7 +1393,7 @@ void QgisMobileapp::clearProject()
{
if ( !mProjectFilePath.isEmpty() )
{
mPluginManager->unloadPlugin( mPluginManager->findProjectPlugin( mProjectFilePath ) );
mPluginManager->unloadPlugin( PluginManager::findProjectPlugin( mProjectFilePath ) );
}
mAuthRequestHandler->clearStoredRealms();

Expand Down

0 comments on commit 55ea0d6

Please sign in to comment.