[Interest] QGuiApplication::commitDataRequest: QML window is not painted

Alexander Dyagilev alervdvcw at gmail.com
Sat Feb 27 14:52:49 CET 2021


Hello,

I'm trying to add quit confirmation message at OS shutdown according to 
this example:
https://doc.qt.io/qt-5/qsessionmanager.html#allowsInteraction

I interact with the user via QML interface. It is asynchronous, so I use 
slots/signals. And I use additional QEventLoop to stay inside of 
QGuiApplication::commitDataRequest call while interacting with the user.

The trouble is that after I shutdown OS - my app prevents OS to shutdown 
and it's good, but its screen is just white, or contains old state 
without the confirmation dialog. I need to hide/restore window or change 
its size, or do some mouse clicks inside of it to force it repaint. When 
it repaint all is OK and my confirmation dialog is there.

Is this a bug? Is there a workaround?

This is the code I use:

voidAppQuitConfirmationAtOsShutdownManager::onCommitDataRequest(

QSessionManager&m)

{

Q_ASSERT_SAME_THREAD;

if(!m_ui->isConfirmationRequired())

return;

if(!m.allowsInteraction())

return;

boolisConfirmed=true;

QEventLooploop;

qtconnect(m_ui.data(),&AppQuitConfirmationUiManager::confirmationResult,

&loop,[&](boolconfirmed)

{

isConfirmed=confirmed;

loop.quit();

},

Qt::QueuedConnection);

m_ui->requestConfirmation();

loop.exec();

m.release();

if(!isConfirmed)

m.cancel();

}



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210227/d1f1ce75/attachment.html>


More information about the Interest mailing list