mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 02:16:04 +08:00
Avoid crash when accessing the main windget position
This commit is contained in:
@@ -659,7 +659,7 @@ namespace BlackGui
|
|||||||
QPoint pos = CGuiUtility::mainWidgetGlobalPosition();
|
QPoint pos = CGuiUtility::mainWidgetGlobalPosition();
|
||||||
if (pos.isNull())
|
if (pos.isNull())
|
||||||
{
|
{
|
||||||
pos = sGui->currentScreen()->geometry().center() - this->rect().center();
|
pos = CGuiApplication::currentScreen()->geometry().center() - this->rect().center();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int x = pos.x() + m_offsetWhenFloating.x();
|
const int x = pos.x() + m_offsetWhenFloating.x();
|
||||||
|
|||||||
@@ -355,7 +355,8 @@ namespace BlackGui
|
|||||||
QRect CGuiApplication::currentScreenGeometry()
|
QRect CGuiApplication::currentScreenGeometry()
|
||||||
{
|
{
|
||||||
const QScreen *s = currentScreen();
|
const QScreen *s = currentScreen();
|
||||||
return s->geometry();
|
if (s) return s->geometry();
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGuiApplication::modalWindowToFront()
|
void CGuiApplication::modalWindowToFront()
|
||||||
|
|||||||
@@ -317,9 +317,13 @@ namespace BlackGui
|
|||||||
|
|
||||||
QPoint CGuiUtility::mainWidgetGlobalPosition()
|
QPoint CGuiUtility::mainWidgetGlobalPosition()
|
||||||
{
|
{
|
||||||
CEnableForFramelessWindow *mw = CGuiUtility::mainFramelessEnabledWindow();
|
QWidget *mw = CGuiUtility::mainApplicationWidget();
|
||||||
if (!mw || !mw->getWidget()) { QPoint(); }
|
if (mw) { return mw->pos(); }
|
||||||
return mw->getWidget()->pos(); // is main window, so not mapToGlobal
|
|
||||||
|
// fallback, can be mfw it is not found
|
||||||
|
CEnableForFramelessWindow *mfw = CGuiUtility::mainFramelessEnabledWindow();
|
||||||
|
if (!mfw || !mfw->getWidget()) { return QPoint(); }
|
||||||
|
return mfw->getWidget()->pos(); // is main window, so not mapToGlobal
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CGuiUtility::replaceTabCountValue(const QString &oldName, int count)
|
QString CGuiUtility::replaceTabCountValue(const QString &oldName, int count)
|
||||||
@@ -353,7 +357,7 @@ namespace BlackGui
|
|||||||
delete widget;
|
delete widget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {delete item;}
|
else { delete item; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// then finally
|
// then finally
|
||||||
|
|||||||
Reference in New Issue
Block a user