Bug 177537 - missing plugin keyword when creating generators
Summary: missing plugin keyword when creating generators
Status: CLOSED FIXED
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Unspecified
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-11 22:38 UTC by David Palacio
Modified: 2009-12-09 19:44 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Palacio 2008-12-11 22:38:03 UTC
Version:            (using Devel)
Installed from:    Compiled sources

In file core/document.cpp line 526 a deprecated method is used.
http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKPluginFactory.html#59613b7a465031d7427d609f7eda76e5

Ruby plugins require the keyword parameter to find the script file. (check kdebindings/ruby/korundum/src/krubypluginfactory.cpp create method)

Please pass parent, keyword and args if necessary/possible
Comment 1 Pino Toscano 2008-12-11 22:57:53 UTC
There's something I don't understand in your report, that makes me think the problem does not lie in Okular.

Let's start from the Okular line:

>    Generator * generator = factory->create< Okular::Generator >( 0 );

and then the various create() overloads in KPluginFactory:

a) T *create(QObject *parent = 0, const QVariantList &args = QVariantList());
b) T *create(const QString &keyword, QObject *parent = 0, const QVariantList &args = QVariantList());
c) T *create(QWidget *parentWidget, QObject *parent, const QString &keyword = QString(), const QVariantList &args = QVariantList());
d) KDE_DEPRECATED T *create(QObject *parent, const QStringList &args)
e) KDE_DEPRECATED QObject *create(QObject *parent = 0, const char *classname = "QObject", const QStringList &args = QStringList())
f) virtual QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword);

it seems pretty clear that (when compiling it) the chosen one is (a).
Let's go to to the implementation of (a):

> inline T *KPluginFactory::create(QObject *parent, const QVariantList &args)
> {
>     QObject *o = create(T::staticMetaObject.className(), parent && parent->isWidgetType() ? reinterpret_cast<QWidget *>(parent): 0, parent, args, QString());

Thus, the create() used by Okular in the end calls the virtual create() that is reimplemented by the KRubyPluginFactory.
Parent is passed (null), keyword is empty, and there are no arguments.

Other ideas?
Comment 2 David Palacio 2008-12-11 23:56:49 UTC
On Thursday 11 December 2008 16:57:53 Pino Toscano wrote:
> There's something I don't understand in your report, that makes me think
> the problem does not lie in Okular.
>
> Let's start from the Okular line:
> >    Generator * generator = factory->create< Okular::Generator >( 0 );
>
> and then the various create() overloads in KPluginFactory:
>
> a) T *create(QObject *parent = 0, const QVariantList &args =
> QVariantList()); b) T *create(const QString &keyword, QObject *parent = 0,
> const QVariantList &args = QVariantList());
> c) T *create(QWidget *parentWidget, QObject *parent, const QString &keyword
> = QString(), const QVariantList &args = QVariantList());
> d) KDE_DEPRECATED T *create(QObject *parent, const QStringList &args)
> e) KDE_DEPRECATED QObject *create(QObject *parent = 0, const char
> *classname = "QObject", const QStringList &args = QStringList())
> f) virtual QObject *create(const char *iface, QWidget *parentWidget,
> QObject *parent, const QVariantList &args, const QString &keyword);
>
> it seems pretty clear that (when compiling it) the chosen one is (a).
Correct. I said that.
> Let's go to to the implementation of (a):
> > inline T *KPluginFactory::create(QObject *parent, const QVariantList
> > &args) {
> >     QObject *o = create(T::staticMetaObject.className(), parent &&
> > parent->isWidgetType() ? reinterpret_cast<QWidget *>(parent): 0, parent,
> > args, QString());
>
> Thus, the create() used by Okular in the end calls the virtual create()
> that is reimplemented by the KRubyPluginFactory.
> Parent is passed (null), keyword is empty, and there are no arguments.
Correct. I said that too.
> Other ideas?
The problem is that the ruby plugin .desktop file contains a X-KDE-PluginKeyword that describes the file to load which is ignored by Okular. This keyword is the one passed to the create method.
X-KDE-PluginKeyword=folder/script.rb

Right now, when I execute this plugin within the Okular kpart, this appears  in the program output:
KRubyPluginFactory::create: Ruby script "" missing

"" is the keyword parameter from KRubyPluginFactory::create
Comment 3 David Palacio 2008-12-12 00:05:45 UTC
I'd read the keyword from KService::keywords()
http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKService.html#f770ba5a418ed2b0c8dfa5d014536e7c

And pass it to the create method.
Comment 4 Pino Toscano 2008-12-12 01:13:43 UTC
> I'd read the keyword from KService::keywords()

Not really, but pluginKeyword().
Confirming and giving a better title, fix coming in a minute.
Comment 5 Pino Toscano 2008-12-12 01:16:24 UTC
SVN commit 895926 by pino:

Pass the plugin keyword when creating generators.
This should make the Ruby binding work again.

BUG: 177537


 M  +1 -1      document.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=895926