Results 1 to 4 of 4

Thread: Crashes when activated

  1. #1
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Crashes when activated

    I have a project where I am communicating with a USB camera.
    I have a slider that controls stuff related to the camera which needs careful checking of the status before sending the control actions to it.
    I got this to work reasonably well, except in one situation:
    When the window is out of focus (e.g. when MacOSX Finder is active and the app window is grey in the background) and I click on the slider to activate the window, the app crashes, the USB is stalling.
    If I click somewhere else on the window to get it in focus (or is it called "activated"?) and THEN touch the slider, it works.

    How can I catch his focus/activate event?
    I probably need to disable slider action in this case?
    MacOSX user dabbling with Linux and Windows.

  2. #2
    Join Date
    Jan 2006
    Location
    Innsbruck, Austria
    Posts
    62
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Crashes when activated

    Do you have any slot connected to that slider? Where did you define the slider? Could you post some relevant code? A backtrace would also be helpful.

  3. #3
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Crashes when activated

    The slots are like this:
    Qt Code:
    1. connect(ZoomSlider, SIGNAL(sliderPressed()), this, SLOT(DoAbort()));
    2. connect(ZoomSlider, SIGNAL(sliderReleased()), this, SLOT(Restart()));
    To copy to clipboard, switch view to plain text mode 
    The camera is doing live imaging, and pressing the slider aborts this.
    The camera should not be active when the slider is moved.
    The camera should restart the live imaging with new parameters when the slider is released at its new position.

    The Stop:
    Qt Code:
    1. void
    2. CameraWindow::DoAbort() {
    3. int rc=0;
    4. if(busy) return;
    5. printf("\nAborting...");
    6. aborting = true;
    7. if(LiveThread->isRunning()) {
    8. busy = true;
    9. rc = AbortCameraLive(); // camera SDK call
    10. LiveThread->wait();
    11. // The camera thread will emit busy=false when finished and ready to reset.
    12. while(busy) QApplication::processEvents();
    13. }
    14. CameraExit(); // camera SDK call
    15. inited = false;
    16. CameraInit(); // camera SDK call
    17. aborting = false;
    To copy to clipboard, switch view to plain text mode 

    And the Restart:
    Qt Code:
    1. void
    2. CameraWindow::Restart()
    3. {
    4. if(busy) return;
    5. if(aborting) return;
    6.  
    7. zoomcontrol = ZoomSlider->value();
    8.  
    9. DelayedLiveDisplay.start(500); // safer
    10. }
    To copy to clipboard, switch view to plain text mode 

    There are surely many ways to do this, but now I am concentrating to get this scheme robust so that sloppy clicking around will not stall the camera.
    MacOSX user dabbling with Linux and Windows.

  4. #4
    Join Date
    Jan 2008
    Posts
    155
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Crashes when activated

    I don't know if this is the final solution, but it certainly helped:

    Qt Code:
    1. void
    2. CameraWindow::DoAbort() {
    3. int rc=0;
    4. QApplication::processEvents(); // << new addition
    5. if(busy) return;
    6. printf("\nAborting...");
    7. aborting = true;
    8. if(LiveThread->isRunning()) {
    9. busy = true;
    10. rc = AbortCameraLive(); // camera SDK call
    11. LiveThread->wait();
    12. // The camera thread will emit busy=false when finished and ready to reset.
    13. while(busy) QApplication::processEvents();
    14. }
    15. CameraExit(); // camera SDK call
    16. inited = false;
    17. CameraInit(); // camera SDK call
    18. aborting = false;
    19. }
    To copy to clipboard, switch view to plain text mode 

    It got much less prone to crash in this situation, and if it still does, it is not crashing in the same way as before
    MacOSX user dabbling with Linux and Windows.

Similar Threads

  1. QSocketNotifier activated() not firing
    By jflatt in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2009, 20:10
  2. Replies: 1
    Last Post: 30th March 2009, 22:25
  3. QGraphicsScene render() crashes
    By iebele in forum Qt Programming
    Replies: 0
    Last Post: 29th April 2008, 13:38
  4. Replies: 10
    Last Post: 19th October 2007, 19:17

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.