Computer falls asleep while Qt Creator is building a large project
-
I am coding FreeCAD on Windows with Qt Creator 4.13.0. A full build of FreeCAD takes more than 25 minutes, and if i leave my laptop unattended, it falls asleep, suspending the build.
It kinda sucks when I leave the laptop compiling, and then come back to find out that laptop fell asleep and FreeCAD isn't even halfway compiled. It would have been nice if Qt Creator could prevent the computer from auto falling asleep until the build is finished.
I have looked through the settings of Qt Creator, and have not found anything for that. Is it possible?
If someone is going to implement it, on windows it can be controlled by SetThreadExecutionState function.
-
Please report this on Qt bugtracker.
-
Shame. I think it would have been a useful feature.
-
It doesn't seem like the right/responsibility of a compiler or maker or builder to keep a computer awake so it keep going. I assume if you want something like this you would need a "governor" service which you told what you wanted to keep awake for from running programs, and prevent sleep of that can be done?
-
@JonB
i'm sure it can be done with a special governor... but being yet another perpetual background process, this solution for me is ugly at best.
My computer doesn't sleep when i talk on skype. I don't have to set up a governor for that, it just works.
My computer plays youtube for however long i like, there is no governor for that. Or plays music.
My computer controls a 3d-printer, doesn't sleep, there is no governor (though i usually still change the power plan to "never sleep" for this very important occasion, for good measure)BTW, Moderns Standby in windows gives me trouble with the music playback (still falls asleep), but that's a topic for another discussion.
-
-
@JonB said in Computer falls asleep while Qt Creator is building a large project:
My computer plays youtube for however long i like
I may [well] be old-fashioned, but I am assuming this means through a web browser, not some "app"(?). In which case, are you saying Google Chrome is making this
SetThreadExecutionState
call?Yes, Chrome. It's really nothing exotic. It's part of WinApi since Windows XP. link
-
@sierdzio
OK, so, don't shoot me, I'm just asking/suggesting: to get the desired behaviour, can the OP write a one-line wrapper around the compiler or make command, or perhaps the invocation of Qt Creator itself, to call the desiredSetThreadExecutionState
? It seems it doesn't matter which application that comes from, so long as that application is running, so any wrapper should do it? -
@JonB
Hi
Yes it works with any tool that sets this.
like this one
https://sourceforge.net/projects/coffeeff/files/
that can see if Creator is running and then do it. -
@JonB
Firefox clearly does call that function while playing youtube. I can see it by executingpowercfg -requests
from elevated command prompt.DISPLAY: [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe [PROCESS] \Device\HarddiskVolume3\Program Files\Mozilla Firefox\firefox.exe SYSTEM: [DRIVER] Realtek High Definition Audio (INTELAUDIO\FUNC_01&VEN_10EC&DEV_0294&SUBSYS_10431AF1&REV_1000\4&298c7770&0&0001) An audio stream is currently in use. AWAYMODE: None. EXECUTION: None. PERFBOOST: None. ACTIVELOCKSCREEN: None.
Winamp does not, apparently, but if only classic sleep (S3) is available, any audio stream keeps the computer awake. On modern sleep (S0), my laptop will sleep when winamp is playing, and it sucks (i have gone through hell to disable S0 on windows 10 v2004, maybe i should have ditched winamp instead).
-
@JonB said in Computer falls asleep while Qt Creator is building a large project:
to get the desired behaviour, can the OP write a one-line wrapper around the compiler or make command, or perhaps the invocation of Qt Creator itself, to call the desired
SetThreadExecutionState
? It seems it doesn't matter which application that comes from, so long as that application is running, so any wrapper should do it?I think it should work. Adding a wrapper for Qt Creator is a bad idea, because i do want my computer to sleep if qt creator is just sitting there doing nothing. But a wrapper around msvc or ninja or maybe even cmake will most likely work.
-
@DeepSOIC
Point taken! And interesting to know.IMHO only, this should not be done by a compiler. And this is all very Windows-specific, while Qt Creator and other Qt stuff is very much platform-independent.
[I wonder whether Visual Studio even bothers to do this. I doubt the MSVC compiler does.]
The bug report was rejected as "Out of Scope" for Qt, which it seems to me it indeed is. @mrjj's link or a one-liner wrapper seems to me the right way to go if you want this, and evidently it's all you can do since Qt devs are making clear they're not going to do it!
-
@DeepSOIC said in Computer falls asleep while Qt Creator is building a large project:
Adding a wrapper for Qt Creator is a bad idea, because i do want my computer to sleep if qt creator is just sitting there doing nothing. But a wrapper around msvc or ninja or maybe even cmake will most likely work.
Yes, absolutely. And in any case it's all you can do from here to get what you want :)
-
@JonB said in Computer falls asleep while Qt Creator is building a large project:
And this is all very Windows-specific, while Qt Creator and other Qt stuff is very much platform-independent.
I don't think the issue itself is platform-specific. SetThreadExecutionState is of course windows-specific. I'm not familiar with linux, macos, chromeos, android, ios. I see some info on macos and linux here: https://stackoverflow.com/questions/31498114/how-to-programmatically-prevent-linux-computer-from-sleeping-or-turning-on-scree
I don't know if the computer will sleep when building a big project with qt creator on any other platform. But I suppose it will.
-
@DeepSOIC
Well, that question shows there isn't anything commonly accepted for Linux?Let's perhaps agree on the following: if the Qt library does not offer a cross-platform anti-sleep (it does not, does it?) then Qt Creator is unlikely to make such a call! Perhaps the first thing would be to lobby for such a method being available from Qt!? :)