<table><tr><td style="">broulik added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D22241">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>So why does KModifierKeyInfo::Private need to be shared?</p></blockquote>

<p>It needs to be refcounted. In <a href="https://phabricator.kde.org/R273:0fe2990dbad992a4925a7b7bee09b1cdfbe5a7a7" style="background-color: #e7e7e7;
          border-color: #e7e7e7;
          border-radius: 3px;
          padding: 0 4px;
          font-weight: bold;
          color: black;text-decoration: none;">0fe2990dbad992a4925a7b7bee09b1cdfbe5a7a7</a> a plugin infrastructure was introduced. Unbeknownst to us the instances are shared internally by Qt.</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">KModifierKeyInfoProvider* createProvider()
{
    QPluginLoader loader(QStringLiteral("kf5/kguiaddons/kmodifierkey/kmodifierkey_")+qGuiApp->platformName());
    auto instance = dynamic_cast<KModifierKeyInfoProvider*>(loader.instance());
    if (instance)
        return instance;
...
 
 KModifierKeyInfo::KModifierKeyInfo(QObject *parent)
    : QObject(parent), p(createProvider())</pre></div>

<p>The <tt style="background: #ebebeb; font-size: 13px;">instance</tt> returned is the same every time despite the <tt style="background: #ebebeb; font-size: 13px;">QPluginLoader</tt> being on the stack.<br />
Now the destructor of <tt style="background: #ebebeb; font-size: 13px;">KModifierKeyInfo</tt> cleans up <tt style="background: #ebebeb; font-size: 13px;">p</tt> and if you have two instances of <tt style="background: #ebebeb; font-size: 13px;">KModifierKeyInfo</tt>, which Kile does for instance, it crashes on double delete.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R273 KGuiAddons</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D22241">https://phabricator.kde.org/D22241</a></div></div><br /><div><strong>To: </strong>apol, broulik<br /><strong>Cc: </strong>davidedmundson, kde-frameworks-devel, LeGast00n, michaelh, ngraham, bruns<br /></div>