Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPluginLoader
Qt 6.11 is out! See what's new in the release blog

QPluginLoader

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thanatos.jsse
    wrote on last edited by
    #1

    Hi Developer Network,

    I'm working over plugin arquitecture aproach, but I have a question about plugin loader.
    If I call QPluginLoader::unload(), the loader free reserved memory for loaded object? or have I call delete operator?.

    @QObject *pluginInstance = m_loader.instance();
    if (!pluginInstance)
    continue;
    PluginFactory *pluginFactory = qobject_cast<PluginFactory *>(pluginInstance);

    if (!pluginFactory)
    continue;

    Plugin *plugin = pluginFactory->plugin(); // PluginFactory::plugin() { return new Plugin(); }

    if (!plugin)
    continue;

    m_loader.unload();

    // delete plugin;@

    Thank you for your help ;)

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      This depends on whether "plugin" is a child (QObject) of pluginInstance/pluginFactory. on mloader.unload(), pluginFactory is deleted. if "plugin" is not associated with the other classes anymore, you're responsible for the memory.

      //EDIT: And since you create it via "new Plugin();" and not "new Plugin(this);", it isn't a child of the factory and you'll need to delete it yourself.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Thanatos.jsse
        wrote on last edited by
        #3

        ;)

        Ok DerManu,

        Thank you for your explanation (about QPluginLoader). I'll check my memory management.

        BR,

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved