<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[plugin cache problem]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">I am developing an application that gets some data from a network device. The data is logged, averaged and shown.<br />
I don't want to kill the application when I change something at showing the data.<br />
Therefore I put the things to show in a plugin which then shows the data in a widget.<br />
After a few days of running I want to be able to change something in the plugin, that shows the data, and reload the plugin.</p>
<p dir="auto">The application works just fine, but I have one problem:<br />
The reloaded plugin remains the same. After changing the plugin source and the files, there is always the old plugin reloaded, which isn't existing anymore on the disk.<br />
Only after restarting the whole application, the new version of the plugin is loaded.<br />
I found out, that I have to change the filename of the plugin to have it working.<br />
So for example, initially i load "<a href="http://plugin1.so" target="_blank" rel="noopener noreferrer nofollow ugc">plugin1.so</a>". If i want to reload it, i have to call it "<a href="http://plugin2.so" target="_blank" rel="noopener noreferrer nofollow ugc">plugin2.so</a>". Then the newer version is loaded.</p>
<p dir="auto">After digging around I found a little bit about "Plugin Cache", but nothing that helps me. Nowhere is mentioned how to clear that cache.</p>
<p dir="auto">So basically everything is working. I can load and reload the plugin, but I don't want to have to change the filename, that the new version of the plugin is loaded instead of the old one.</p>
<p dir="auto">I am working on Ubuntu 18.04.05 with Qt 5.11.1 and Qt 5.12.10. (5.12.10 is the latest offline installer version currently).</p>
<p dir="auto">Here is my code which is loading and reloading the plugin:</p>
<pre><code>void energymanager_class::load_plugin(plugin_struct *plugin, QString filename, QWidget *widget) {
    if(plugin-&gt;loaded == true) {
        return;
    }

    plugin-&gt;filename = filename;
    plugin-&gt;loader = new QPluginLoader();
    plugin-&gt;loader-&gt;setFileName(plugin-&gt;filename);
    plugin-&gt;instance = plugin-&gt;loader-&gt;instance();
    if(plugin-&gt;instance) {
        plugin-&gt;loaded = 1;
        plugin-&gt;error = 0;
        plugin-&gt;interface = qobject_cast&lt;plugin_interface_class*&gt;(plugin-&gt;instance);
        plugin-&gt;widget = new QWidget();
        plugin-&gt;widget-&gt;setParent(widget);
        plugin-&gt;widget-&gt;show();
        plugin-&gt;interface-&gt;set_gen24data_pointer(gen24_data);
        connect(plugin-&gt;interface-&gt;get_object(), SIGNAL(newdataavailable_signal()), this, SLOT(newdataavailable_slot()), Qt::DirectConnection);
        connect(this, SIGNAL(newdataavailable_signal()), plugin-&gt;interface-&gt;get_object(), SLOT(newdataavailable_slot()), Qt::DirectConnection);
        plugin-&gt;interface-&gt;load_ui(plugin-&gt;widget);
        plugin-&gt;interface-&gt;init();
    } else {
        plugin-&gt;loaded = 0;
        plugin-&gt;error = 1;
        plugin-&gt;errorstring = QString("Plugin konnte nicht geladen werden. loader errorString: %1").arg(plugin-&gt;loader-&gt;errorString());
        qDebug() &lt;&lt; plugin-&gt;errorstring;
    }
}

void energymanager_class::unload_plugin(plugin_struct *plugin) {
    plugin-&gt;interface-&gt;deinit();
    plugin-&gt;interface-&gt;unload_ui();
    plugin-&gt;loader-&gt;unload();

    QPluginLoader* loader = plugin-&gt;loader;
    delete loader;

    QWidget* pluginwidget = plugin-&gt;widget;
    delete pluginwidget;

    zero.zero_plugin(plugin);
}

void energymanager_class::on_reload_energyflow_triggered() {
    unload_plugin(&amp;plugin_energyflow);
    load_plugin(&amp;plugin_energyflow, "plugins/plugin_energyflow.so", ui-&gt;widget_energyflow);
    formsizechanged();
}
</code></pre>
<p dir="auto">First load_plugin() is called and the plugin is shown.<br />
After a few days I change the plugin source, recompile it and call on_reload_energyflow_triggered().<br />
The plugin is reloaded (correctly it seems), but with the old version instead of the new version. The old version isn't existing anymore on the disk.</p>
<p dir="auto">How to reload to the new version and flush the plugin cache?</p>
]]></description><link>https://forum.qt.io/topic/124706/plugin-cache-problem</link><generator>RSS for Node</generator><lastBuildDate>Tue, 19 May 2026 16:10:05 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/124706.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 13 Mar 2021 17:35:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to plugin cache problem on Thu, 24 Apr 2025 17:30:52 GMT]]></title><description><![CDATA[<p dir="auto">In windows cache is located in the registry</p>
]]></description><link>https://forum.qt.io/post/825141</link><guid isPermaLink="true">https://forum.qt.io/post/825141</guid><dc:creator><![CDATA[Leonid_Kov]]></dc:creator><pubDate>Thu, 24 Apr 2025 17:30:52 GMT</pubDate></item><item><title><![CDATA[Reply to plugin cache problem on Sat, 13 Mar 2021 20:02:37 GMT]]></title><description><![CDATA[<p dir="auto">Yeah thats weird...<br />
It also doesn't make sense for me, but it is working.</p>
<ol>
<li>I change the source of the plugin</li>
<li>I compile the new version</li>
<li>The old plugin is unloaded (by the main application)</li>
<li>The new plugin file is renamed to anything other than before (by the main application) (to fool the cache)</li>
<li>The new plugin is loaded fine (by the main application)</li>
<li>The new plugin is renamed to the old filename (by the main application)</li>
<li>Everything is fine.</li>
</ol>
<p dir="auto">If I don't do the renaming, the old version of the plugin is loaded again although it has <em>definately</em> been replaced on disk.</p>
]]></description><link>https://forum.qt.io/post/649436</link><guid isPermaLink="true">https://forum.qt.io/post/649436</guid><dc:creator><![CDATA[churchi]]></dc:creator><pubDate>Sat, 13 Mar 2021 20:02:37 GMT</pubDate></item><item><title><![CDATA[Reply to plugin cache problem on Sat, 13 Mar 2021 19:43:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/churchi">@<bdi>churchi</bdi></a> said in <a href="/post/649425">plugin cache problem</a>:</p>
<blockquote>
<p dir="auto">My current solution for the problem is renaming the plugin before loading, and renaming it back after loading.</p>
</blockquote>
<p dir="auto">I don't understand what you're trying to tell me.</p>
]]></description><link>https://forum.qt.io/post/649429</link><guid isPermaLink="true">https://forum.qt.io/post/649429</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Sat, 13 Mar 2021 19:43:26 GMT</pubDate></item><item><title><![CDATA[Reply to plugin cache problem on Sat, 13 Mar 2021 18:59:23 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the hint, but its taking the correct files.</p>
<p dir="auto">My current solution for the problem is renaming the plugin before loading, and renaming it back after loading.<br />
This is really a verry shitty solution. But its working?</p>
<pre><code>void energymanager_class::on_reload_energyflow_triggered() {
    QString filename = plugin_energyflow_filename;
    QString filename_new = filename;
    filename_new.append(QString("%1").arg(QDateTime::currentMSecsSinceEpoch()));
    QFile::rename(filename, filename_new);
    unload_plugin(&amp;plugin_energyflow);
    load_plugin(&amp;plugin_energyflow, filename_new, ui-&gt;widget_energyflow);
    QFile::rename(filename_new, filename);
    formsizechanged();
}
</code></pre>
<p dir="auto">So just renaming the file for short is of course bypassing the cache and makes a workaround. But to be honest - i don't want it like that...</p>
]]></description><link>https://forum.qt.io/post/649425</link><guid isPermaLink="true">https://forum.qt.io/post/649425</guid><dc:creator><![CDATA[churchi]]></dc:creator><pubDate>Sat, 13 Mar 2021 18:59:23 GMT</pubDate></item><item><title><![CDATA[Reply to plugin cache problem on Sat, 13 Mar 2021 17:45:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/churchi">@<bdi>churchi</bdi></a> said in <a href="/post/649414">plugin cache problem</a>:</p>
<blockquote>
<p dir="auto">The old version isn't existing anymore on the disk.</p>
</blockquote>
<p dir="auto">For sure it is somewhere. Start with env variable <a href="https://doc.qt.io/qt-5/debug.html" target="_blank" rel="noopener noreferrer nofollow ugc">QT_DEBUG_PLUGINS</a> and see from where it is loaded.</p>
]]></description><link>https://forum.qt.io/post/649415</link><guid isPermaLink="true">https://forum.qt.io/post/649415</guid><dc:creator><![CDATA[Christian Ehrlicher]]></dc:creator><pubDate>Sat, 13 Mar 2021 17:45:44 GMT</pubDate></item></channel></rss>