Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Marble
Commits
b1e3590f
Commit
b1e3590f
authored
Aug 03, 2020
by
Volker Krause
Browse files
Add support for loading static plugins
parent
7cec0d52
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/marble/PluginManager.cpp
View file @
b1e3590f
...
...
@@ -45,6 +45,7 @@ class PluginManagerPrivate
~
PluginManagerPrivate
();
void
loadPlugins
();
bool
addPlugin
(
QObject
*
obj
,
const
QPluginLoader
*
loader
);
bool
m_pluginsLoaded
;
QList
<
const
RenderPlugin
*>
m_renderPluginTemplates
;
...
...
@@ -189,6 +190,28 @@ bool appendPlugin( QObject * obj, const QPluginLoader *loader, QList<Plugin> &pl
return
false
;
}
bool
PluginManagerPrivate
::
addPlugin
(
QObject
*
obj
,
const
QPluginLoader
*
loader
)
{
bool
isPlugin
=
appendPlugin
<
RenderPluginInterface
>
(
obj
,
loader
,
m_renderPluginTemplates
);
isPlugin
=
isPlugin
||
appendPlugin
<
PositionProviderPluginInterface
>
(
obj
,
loader
,
m_positionProviderPluginTemplates
);
isPlugin
=
isPlugin
||
appendPlugin
<
SearchRunnerPlugin
>
(
obj
,
loader
,
m_searchRunnerPlugins
);
isPlugin
=
isPlugin
||
appendPlugin
<
ReverseGeocodingRunnerPlugin
>
(
obj
,
loader
,
m_reverseGeocodingRunnerPlugins
);
isPlugin
=
isPlugin
||
appendPlugin
<
RoutingRunnerPlugin
>
(
obj
,
loader
,
m_routingRunnerPlugins
);
isPlugin
=
isPlugin
||
appendPlugin
<
ParseRunnerPlugin
>
(
obj
,
loader
,
m_parsingRunnerPlugins
);
if
(
!
isPlugin
)
{
qWarning
()
<<
"Ignoring the following plugin since it couldn't be loaded:"
<<
(
loader
?
loader
->
fileName
()
:
"<static>"
);
mDebug
()
<<
"Plugin failure:"
<<
(
loader
?
loader
->
fileName
()
:
"<static>"
)
<<
"is a plugin, but it does not implement the "
<<
"right interfaces or it was compiled against an old version of Marble. Ignoring it."
;
}
return
isPlugin
;
}
void
PluginManagerPrivate
::
loadPlugins
()
{
if
(
m_pluginsLoaded
)
...
...
@@ -238,22 +261,8 @@ void PluginManagerPrivate::loadPlugins()
QObject
*
obj
=
loader
->
instance
();
if
(
obj
)
{
bool
isPlugin
=
appendPlugin
<
RenderPluginInterface
>
(
obj
,
loader
,
m_renderPluginTemplates
);
isPlugin
=
isPlugin
||
appendPlugin
<
PositionProviderPluginInterface
>
(
obj
,
loader
,
m_positionProviderPluginTemplates
);
isPlugin
=
isPlugin
||
appendPlugin
<
SearchRunnerPlugin
>
(
obj
,
loader
,
m_searchRunnerPlugins
);
// intentionally T==U
isPlugin
=
isPlugin
||
appendPlugin
<
ReverseGeocodingRunnerPlugin
>
(
obj
,
loader
,
m_reverseGeocodingRunnerPlugins
);
// intentionally T==U
isPlugin
=
isPlugin
||
appendPlugin
<
RoutingRunnerPlugin
>
(
obj
,
loader
,
m_routingRunnerPlugins
);
// intentionally T==U
isPlugin
=
isPlugin
||
appendPlugin
<
ParseRunnerPlugin
>
(
obj
,
loader
,
m_parsingRunnerPlugins
);
// intentionally T==U
if
(
!
isPlugin
)
{
qWarning
()
<<
"Ignoring the following plugin since it couldn't be loaded:"
<<
path
;
mDebug
()
<<
"Plugin failure:"
<<
path
<<
"is a plugin, but it does not implement the "
<<
"right interfaces or it was compiled against an old version of Marble. Ignoring it."
;
bool
isPlugin
=
addPlugin
(
obj
,
loader
);
if
(
!
isPlugin
)
{
delete
loader
;
}
else
{
foundPlugin
=
true
;
...
...
@@ -265,6 +274,13 @@ void PluginManagerPrivate::loadPlugins()
}
}
const
auto
staticPlugins
=
QPluginLoader
::
staticInstances
();
for
(
auto
obj
:
staticPlugins
)
{
if
(
addPlugin
(
obj
,
nullptr
))
{
foundPlugin
=
true
;
}
}
if
(
!
foundPlugin
)
{
#ifdef Q_OS_WIN
QString
pluginPaths
=
"Plugin Path: "
+
MarbleDirs
::
marblePluginPath
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment