Commit 119ff05c authored by Eike Ziller's avatar Eike Ziller

Help: Make restoring override cursor more robust

Some help backends are not too consistent in how they send started and
finished signals (QtWebEngine I'm looking at you), so make restoring the
override cursor more robust in the base. As long as the backend reports
that it is finished, guarantee that all previous override cursors are
restored.
Also ensure override cursors are restored in case the viewer is
destroyed.

Task-number: QTCREATORBUG-17758
Change-Id: Icb1cd1eabfb232135a391a550d8e6719a74189eb
Reviewed-by: Alexandru Croitor's avatarAlexandru Croitor <alexandru.croitor@qt.io>
parent 024cfda0
......@@ -85,6 +85,11 @@ HelpViewer::HelpViewer(QWidget *parent)
{
}
HelpViewer::~HelpViewer()
{
restoreOverrideCursor();
}
void HelpViewer::setActionVisible(Action action, bool visible)
{
if (visible)
......@@ -156,16 +161,25 @@ void HelpViewer::home()
void HelpViewer::slotLoadStarted()
{
++m_loadOverrideStack;
QGuiApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
}
void HelpViewer::slotLoadFinished()
{
QGuiApplication::restoreOverrideCursor();
restoreOverrideCursor();
emit sourceChanged(source());
emit loadFinished();
}
void HelpViewer::restoreOverrideCursor()
{
while (m_loadOverrideStack > 0) {
--m_loadOverrideStack;
QGuiApplication::restoreOverrideCursor();
}
}
bool HelpViewer::handleForwardBackwardMouseButtons(QMouseEvent *event)
{
if (event->button() == Qt::XButton1) {
......
......@@ -49,7 +49,7 @@ public:
Q_DECLARE_FLAGS(Actions, Action)
explicit HelpViewer(QWidget *parent = 0);
~HelpViewer() { }
~HelpViewer();
virtual QFont viewerFont() const = 0;
virtual void setViewerFont(const QFont &font) = 0;
......@@ -109,7 +109,10 @@ protected:
void slotLoadStarted();
void slotLoadFinished();
void restoreOverrideCursor();
Actions m_visibleActions = 0;
int m_loadOverrideStack = 0;
};
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment