Bug 352471 - KPluginSelector::addPlugins() says last 'config' parameter can be default, but asserts if it is
Summary: KPluginSelector::addPlugins() says last 'config' parameter can be default, bu...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kcmutils
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-09 10:01 UTC by Jonathan Marten
Modified: 2015-12-21 08:55 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 Jonathan Marten 2015-09-09 10:01:47 UTC
Using the KF5 version of Konqueror and selecting Settings - Configure Extensions from the menu crashes with the following assert (irrelevant threads and bottom of stack trimmed):

konqueror(15498)/default qt_assert: ASSERT: "config" in file /ws/frameworks/tier3/kcmutils/src/kpluginselector.cpp, line 320

Application: Konqueror (konqueror), signal: Aborted
Using host libthread_db library "/lib64/libthread_db.so.1".
[Current thread is 1 (Thread 0x7fb2ca917800 (LWP 15498))]
Thread 1 (Thread 0x7fb2ca917800 (LWP 15498)):
[KCrash Handler]
#6  0x00007fb2c2ccc417 in raise () from /lib64/libc.so.6
#7  0x00007fb2c2ccd9dd in abort () from /lib64/libc.so.6
#8  0x00007fb2c4262bae in qt_message_fatal (context=..., message=<synthetic pointer>) at global/qlogging.cpp:1578
#9  QMessageLogger::fatal (this=this@entry=0x7fffb3722e50, msg=msg@entry=0x7fb2c4519e48 "ASSERT: \"%s\" in file %s, line %d") at global/qlogging.cpp:781
#10 0x00007fb2c425c174 in qt_assert (assertion=assertion@entry=0x7fb2c9d55a34 "config", file=file@entry=0x7fb2c9d559b8 "/ws/frameworks/tier3/kcmutils/src/kpluginselector.cpp", line=line@entry=320) at global/qglobal.cpp:2966
#11 0x00007fb2c9d45364 in KPluginSelector::addPlugins (this=0x1fafd20, componentName=..., categoryName=..., categoryKey=..., config=...) at /ws/frameworks/tier3/kcmutils/src/kpluginselector.cpp:320
#12 0x00007fb2ca68351f in KonqExtensionManager::KonqExtensionManager (this=0x7fffb3723010, parent=<optimized out>, mainWindow=<optimized out>, activePart=0x1dd4a20) at /ws/frameworks/applications/kdebaseapps/konqueror/src/konqextensionmanager.cpp:76
#13 0x00007fb2ca66e198 in KonqMainWindow::slotConfigureExtensions (this=<optimized out>) at /ws/frameworks/applications/kdebaseapps/konqueror/src/konqmainwindow.cpp:1821

KonqExtensionManager::KonqExtensionManager() is calling KPluginSelector:;addPlugins() with 3 parameters (in the second and third calls):

    d->pluginSelector->addPlugins("konqueror", i18n("Extensions"), "Extensions", KSharedConfig::openConfig());
    if ( activePart ) {
        KAboutData componentData = activePart->componentData();
        d->pluginSelector->addPlugins(componentData.componentName(), i18n("Extensions"), "Tools");
        d->pluginSelector->addPlugins(componentData.componentName(), i18n("Extensions"), "Statusbar");
    }

According to the KPluginSelector::addPlugins() API documentation (for the 4-parameter form), the default for the last 'config' parameter uses the component name.  However, the code seems to have an assert *before* taking the default:

void KPluginSelector::addPlugins(const QString &componentName,
                                 const QString &categoryName,
                                 const QString &categoryKey,
                                 KSharedConfig::Ptr config)
{
    [snip...]
    Q_ASSERT(config);
    if (!config) {
        config = KSharedConfig::openConfig(componentName + QStringLiteral("rc"));
    }

so calling this with a null 'config' will always trigger the assert.


Reproducible: Always

Steps to Reproduce:
1.  Run 'konqueror about:blank'
2.  Select Settings - Configure Extensions from the menu.




Maybe the Q_ASSERT should come after the if (!config) block?
Comment 1 Jonathan Marten 2015-09-09 10:07:55 UTC
With the patch:

--- a/src/kpluginselector.cpp
+++ b/src/kpluginselector.cpp
@@ -317,10 +317,10 @@ void KPluginSelector::addPlugins(const QString &componentName,
         return;
     }

-    Q_ASSERT(config);
     if (!config) {
         config = KSharedConfig::openConfig(componentName + QStringLiteral("rc"));
     }
+    Q_ASSERT(config);

     KConfigGroup cfgGroup(config, "KParts Plugins");
     // qDebug() << "cfgGroup = " << &cfgGroup;

there is no assert, the list of plugins is shown and the configuration works.
Comment 2 Jonathan Marten 2015-12-19 08:35:03 UTC
https://git.reviewboard.kde.org/r/126423/
Comment 3 Jonathan Marten 2015-12-21 08:55:16 UTC
Git commit 1ae59b5f0ea4f50b7350f03fd2b1fe223f66a261 by Jonathan Marten.
Committed on 21/12/2015 at 08:52.
Pushed by marten into branch 'master'.

KPluginSelector::addPlugins: fix assert if 'config' parameter is default

REVIEW:126423

M  +1    -1    src/kpluginselector.cpp

http://commits.kde.org/kcmutils/1ae59b5f0ea4f50b7350f03fd2b1fe223f66a261