Results 1 to 9 of 9

Thread: How to use QPluginLoader to load plugin as a service so the main app won't crash?

  1. #1
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to use QPluginLoader to load plugin as a service so the main app won't crash?

    Hi,

    It seems to be a new hype those days to load plugins as a service which prevents the app loading the plugin to crash if a plugin fails. A nice example of this is google chrome. One tab can crash but others stay alive.

    Now i'm wondering if it's possible with QPluginLoader to load and use a plugin as a service so the main app won't crash if the plugin does..?

    I did search for this but i don't quite know how that technique is called..

    Anyway, is there an howto about this stuff somewhere?

    Thanx,
    Mark
    Last edited by markg85; 21st December 2009 at 15:43.

  2. The following user says thank you to markg85 for this useful post:

    pezmaster31 (21st December 2009)

  3. #2
    Join Date
    Dec 2009
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to use QPluginLoader to load plugin as a service so the main app won't crash?

    Take a look at the QtPlugins section of the Qt Documentation, what you are looking for is in the Low Level API section.

    Hope that helps.

    http://doc.qt.nokia.com/4.6/plugins-howto.html

  4. #3
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to use QPluginLoader to load plugin as a service so the main app won't crash?

    Quote Originally Posted by sngskunk View Post
    Take a look at the QtPlugins section of the Qt Documentation, what you are looking for is in the Low Level API section.

    Hope that helps.

    http://doc.qt.nokia.com/4.6/plugins-howto.html
    I read the text there but couldn't quite figure out where the part is that causes plugins to be loaded as a service.. A howto or more detailed article on this subject would be very welcome.

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to use QPluginLoader to load plugin as a service so the main app won't crash?

    You might have to explain what you mean by "as a service". You can choose to load or not load a plugin dynamically, is that what you are after? Alternatively, are you after a way to 'sandbox' a plugin so that no matter what crashing it does the remainder of the program stays running?

    Qt plugins are, once loaded, essentially directly executed code. Google Chrome is more a collection of coupled processes using some sort of RPC that I think you'd have to code yourself in Qt. http://blog.chromium.org/2008/09/mul...hitecture.html
    Last edited by ChrisW67; 23rd December 2009 at 06:41.

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

    Default Re: How to use QPluginLoader to load plugin as a service so the main app won't crash?

    Quote Originally Posted by markg85 View Post
    It seems to be a new hype those days to load plugins as a service which prevents the app loading the plugin to crash if a plugin fails.
    One application is not a trend. And Chrome's tabs are not plugins by any means, at least not in the widespread meaning of that word - it's rather a master-slave architecture.
    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.


  7. #6
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to use QPluginLoader to load plugin as a service so the main app won't crash?

    Quote Originally Posted by ChrisW67 View Post
    You might have to explain what you mean by "as a service". You can choose to load or not load a plugin dynamically, is that what you are after? Alternatively, are you after a way to 'sandbox' a plugin so that no matter what crashing it does the remainder of the program stays running?
    That is exactly what i want! How do you call something like that (might ease searching for it a bit ^_^)

    Qt plugins are, once loaded, essentially directly executed code. Google Chrome is more a collection of coupled processes using some sort of RPC that I think you'd have to code yourself in Qt. http://blog.chromium.org/2008/09/mul...hitecture.html
    Google Chrome was just an example where one tab can crash without crashing the app. It's not a plugin.. i know.

    Quote Originally Posted by wysota View Post
    One application is not a trend. And Chrome's tabs are not plugins by any means, at least not in the widespread meaning of that word - it's rather a master-slave architecture.
    So this type of things are called a master-slave architecture? so in my case that would be a plugin master-slave architecture?

    And just to clear it up. (sorry for not doing so in my first post) What i want to do is make an application. That application itself is the "plugin core". Then i want to have the ability to add plugins to that application that add functionallity to the main application. Lets take a music player as an example.

    For a music player this would be the main app:
    - Core plugin engine

    Then to play music it requires plugins:
    - Plugin to play mp3 files
    - Plugin to play mms streams
    - Plugin to show a gui
    etcetera...

    Now when you play a MMS stream and for whatever reason the mp3 plugin crashes it should just crash and leave the program working but just without that plugin.

    I can make the plugin structure (i already have that) but all i'm looking into now is the possibility of letting a plugin crash without crashing the application or other plugins

    Hope that helps to clear it up. Will put it in my first post as well.
    edit:// oh, can't edit my first post anymore..

  8. #7
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to use QPluginLoader to load plugin as a service so the main app won't crash?

    If you don't (or can't) implement a client/server (or master/slave, or whatever you want to call this type of distributed application), then I would suggest that you carefully wrap all calls from the plugin into your driver app with try/catch clauses so you can trap any execution faults that occur in the plugin and handle them appropriately.

    I don't know if there is anything you can do to protect your app from memory corruption caused by the plugin; if it's going to overwrite your app's memory, you're hosed.

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

    Default Re: How to use QPluginLoader to load plugin as a service so the main app won't crash?

    Quote Originally Posted by markg85 View Post
    So this type of things are called a master-slave architecture? so in my case that would be a plugin master-slave architecture?
    Your "plugin core" is a master that communicates with the other processes that do slave work on its behalf. It's a very complex architecture when talking about processes. I suggest you avoid it and use regular plugins that can crash your app. Implement them properly and they will not crash.
    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.


  10. #9
    Join Date
    Dec 2009
    Posts
    6
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to use QPluginLoader to load plugin as a service so the main app won't crash?

    Quote Originally Posted by wysota View Post
    Your "plugin core" is a master that communicates with the other processes that do slave work on its behalf. It's a very complex architecture when talking about processes. I suggest you avoid it and use regular plugins that can crash your app. Implement them properly and they will not crash.
    ^_^ i think i will just do that.
    I was only curious how such things could be done but i guess for the moment it's better to chech every single thing that comes from a plugin (which has to be done always anyways) and just get that working the way i want. Perhaps this can be done sometime in the future. As it stands now it's to complex for me to "just" do.

    Thanx to all for the reply's.

Similar Threads

  1. QPluginLoader doesn't load plugin
    By BeS in forum Qt Programming
    Replies: 6
    Last Post: 26th November 2008, 19:12
  2. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 14:13

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.