Results 1 to 7 of 7

Thread: QTimer is stopped while screen is locked

  1. #1
    Join Date
    Apr 2009
    Posts
    29
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default QTimer is stopped while screen is locked

    I have just switched from Qt 4 to Qt 5.5 and found out that the behaviour of QTimer is different. When the session is automatically locked after 10 minutes of idle (Xubuntu / Light Locker) QTimer stops working and my application also stops working until the session is unlocked and the desktop appears.

    I have tested the behaviour with this small app:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
    2. {
    3. ui->setupUi(this);
    4.  
    5. QTimer *timer = new QTimer(this);
    6. connect(timer, SIGNAL(timeout()), this, SLOT(update()));
    7. timer->start(1000);
    8. }
    9.  
    10. void MainWindow::update(){
    11. ui->textEdit->append(QTime::currentTime().toString("hh:mm:ss"));
    12. }
    To copy to clipboard, switch view to plain text mode 

    And the timer stops after the session is locked:
    13:43:01
    13:43:02
    13:43:03 <-- Session locked
    13:43:36 <-- Session unlocked
    13:43:37

    Is this a bug or new feature? Qt 4.x works fine but Qt 5.5 do not. Is there a way to workaround this behaviour because my application also stop working while the session / screen is locked?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,418
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTimer is stopped while screen is locked

    That is strange.

    Can you try writing the timestamp to a file instead of appending to the text edit?
    Maybe also try doing the same with a QCoreApplication and no UI at all, just to see if that has any impact.

    Cheers,
    _

  3. #3
    Join Date
    Apr 2009
    Posts
    29
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: QTimer is stopped while screen is locked

    Thank you for your reply.
    Quote Originally Posted by anda_skoa View Post
    That is strange.
    Can you try writing the timestamp to a file instead of appending to the text edit?
    This make no difference, the QTimer will be stopped when the session is locked.

    Maybe also try doing the same with a QCoreApplication and no UI at all, just to see if that has any impact.
    Okay this works like expected and the QTimer works in the background. Is this a bug which should be reported?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,418
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTimer is stopped while screen is locked

    Quote Originally Posted by Fred View Post
    Okay this works like expected and the QTimer works in the background. Is this a bug which should be reported?
    Sounds like it.
    Nothing should really block the main event loop.

    Would be interesting to try to narrow it further down.
    Does it also happen when the application object is a QGuiApplication but there is no window.
    If that works, does it also work with a QApplication and no window.
    Or with a QGuiApplication and a plain QWindow.

    Cheers,
    _

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

    Default Re: QTimer is stopped while screen is locked

    Could it be a "feature" of the desktop environment that it sigstops all gui apps when the session is locked?
    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.


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

    Default Re: QTimer is stopped while screen is locked

    I would think that an exceptionally dumb "feature" Which would affect the Qt 4 version equally.
    Last edited by ChrisW67; 10th July 2015 at 21:27.

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

    Default Re: QTimer is stopped while screen is locked

    So would I but then I wouldn't expect a screen locker to affect event flow of other applications.
    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. QTemporaryFile stays locked even after calling close()
    By Tiansen in forum Qt Programming
    Replies: 1
    Last Post: 20th May 2010, 13:35
  2. Removing locked attribute on Mac locked files?
    By gfunk in forum Qt Programming
    Replies: 1
    Last Post: 26th October 2007, 22:40
  3. QTimer based Splash Screen
    By bpetty in forum Newbie
    Replies: 6
    Last Post: 15th December 2006, 00:51
  4. Detect locked files
    By Harvey West in forum Qt Programming
    Replies: 2
    Last Post: 12th December 2006, 15:33

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.