Results 1 to 3 of 3

Thread: Calling QApplication from a Non-QT app?

  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Calling QApplication from a Non-QT app?

    Hello all,

    I have noticed some strange behavior in my app. So here is a quick summary of what i'm doing:
    - I have a non-QT app (Photoshop).
    - I'm creating a plugin which has to use Threading and Widgets (So i need a QApplication instance).
    - Photoshop starts the application several times without "freeing" static data...
    - In the main plugin method, i do like this:
    Qt Code:
    1. bool bUserAccepted = false;
    2. {
    3. ILogger::Log(LOGLEVEL_DEBUG, "Now starting the GUI...");
    4. try {
    5. // Initialize the QT engine.
    6. int iArgC = 0;
    7. static QApplication app (iArgC, NULL);
    8. CWndMainImpl cMainWin((HWND)((PlatformData*)gFilterRecord->platformData)->hwnd, pInPlane, pOutPlane);
    9. app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()) );
    10. cMainWin.show();
    11. app.exec();
    12. bUserAccepted = cMainWin.bAccepted;
    13. } catch(...) {
    14. throw CGenericEx("Unable to display the GUI.", __FILE__, __LINE__);
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    I'm not getting any exception, at least at the begining. But after some times without restarting Photoshop, i'm getting some random errors... Sometimes Photoshop just crash, sometimes i get an unknown exception thrown out. So i'm wondering, can it be some static data QApplication allocates, which are supposed to be only allocated once? Maybe i'm doing something wrong with the connect slot to quit, what do you suggest?

    Thanks for your answers ^^
    Pierre.

  2. #2
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Calling QApplication from a Non-QT app?

    Anyone have suggestions? Even guesses will help me

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Calling QApplication from a Non-QT app?

    As far as I can tell it could be anything.
    From what you posted its hard to tell where the problem resides.
    You say there are some global variables - so it COULD be that two processes are trying to access the same resource at the same time. (so a problem between processes)
    It could be a bug in your plugin.
    Or may be this thread could be interesting:
    http://www.qtcentre.org/forum/f-qt-p...tion-6474.html
    Both points are good for consideration - QApplication singelton, and staic variables initialization.
    At least for me there is too little information to tell.

Similar Threads

  1. Replies: 2
    Last Post: 16th March 2007, 09:04
  2. Replies: 4
    Last Post: 10th March 2007, 18:01
  3. Setting style in QApplication
    By Doug Broadwell in forum Newbie
    Replies: 2
    Last Post: 28th October 2006, 21:56
  4. qapplication with open(/dev/name,O_RDWR) crashed???
    By ttbug in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 16th September 2006, 07:56
  5. Reponsabilities of QApplication and QMainWindow classes
    By yellowmat in forum Qt Programming
    Replies: 4
    Last Post: 4th September 2006, 16:21

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.