Results 1 to 8 of 8

Thread: Plugin destruction

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Plugin destruction

    The plugin loader can only hold a reference to one instance at a time. If you reuse the same instance of QPluginLoader for many plugins then you are responsible for deleting all the objects yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Oct 2009
    Posts
    70

    Default Re: Plugin destruction

    Ok,
    I've correct my code, but the problem is the same:

    To call the destructor of the plugin I need to call the unload() function of the QPluginLoader.

    Is it an expected behaviour?

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Plugin destruction

    You mean that if you do:

    Qt Code:
    1. QObjectList list;
    2. list << loader.instance();
    To copy to clipboard, switch view to plain text mode 

    and then:

    Qt Code:
    1. foreach(QObject *o, list) delete o;
    To copy to clipboard, switch view to plain text mode 
    the destructor is not called?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Oct 2009
    Posts
    70

    Default Re: Plugin destruction

    I've a plugin that handle a thread that do some work.
    When the app is closed, I want to be sure that this plugin close all the worker thread.
    To do this I want to run some code during the closure of the plugin.
    At the start I think to do this on the plugin destructor but I test that without unload() the pluginLoader the plugin destructor is not invoked.
    On the Qt examples there is not pluginLoader unload() and when the app is closed no plugin destructor is invoked.

    My questions:

    As your opinion, has any sense to put any code on the plugin destructor, or I need to call another plugin method to do this operation before the plugin is closed??

    Does I need to call the unload() function of the pluginLoader?

    Which is the safe mode to delete the plugin instances?

    Many thanks

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Plugin destruction

    Quote Originally Posted by paolom View Post
    When the app is closed, I want to be sure that this plugin close all the worker thread.
    To do this I want to run some code during the closure of the plugin.
    You shouldn't do that using a destructor but rather a dedicated close() method that each plugin implements and that your plugin handling infrastructure calls before closing the whole system.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How QDeclarativeView destruction
    By xman_ss in forum Qt Programming
    Replies: 3
    Last Post: 27th April 2012, 07:55
  2. Destruction in separate threads
    By KevinKnowles in forum Qt Programming
    Replies: 3
    Last Post: 19th March 2012, 09:49
  3. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  4. What happens after closing and before destruction?
    By Raccoon29 in forum Qt Programming
    Replies: 45
    Last Post: 20th May 2008, 09:33
  5. processEvents preventing class from destruction?
    By bowser in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 4th January 2008, 17:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.