mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +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();
|
||||
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();
|
||||
|
||||
@@ -355,7 +355,8 @@ namespace BlackGui
|
||||
QRect CGuiApplication::currentScreenGeometry()
|
||||
{
|
||||
const QScreen *s = currentScreen();
|
||||
return s->geometry();
|
||||
if (s) return s->geometry();
|
||||
return {};
|
||||
}
|
||||
|
||||
void CGuiApplication::modalWindowToFront()
|
||||
|
||||
@@ -317,9 +317,13 @@ namespace BlackGui
|
||||
|
||||
QPoint CGuiUtility::mainWidgetGlobalPosition()
|
||||
{
|
||||
CEnableForFramelessWindow *mw = CGuiUtility::mainFramelessEnabledWindow();
|
||||
if (!mw || !mw->getWidget()) { QPoint(); }
|
||||
return mw->getWidget()->pos(); // is main window, so not mapToGlobal
|
||||
QWidget *mw = CGuiUtility::mainApplicationWidget();
|
||||
if (mw) { return mw->pos(); }
|
||||
|
||||
// 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)
|
||||
@@ -353,7 +357,7 @@ namespace BlackGui
|
||||
delete widget;
|
||||
}
|
||||
}
|
||||
else {delete item;}
|
||||
else { delete item; }
|
||||
}
|
||||
|
||||
// then finally
|
||||
|
||||
Reference in New Issue
Block a user