win: fix null pointer access in some rare cases

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-09-01 10:51:50 +08:00
parent 012721d9a0
commit 6b1a37a82a
2 changed files with 6 additions and 5 deletions

View File

@ -531,11 +531,6 @@ static inline void themeChangeNotificationCallback()
void Utils::registerThemeChangeNotification()
{
static bool reg = false;
if (reg) {
return;
}
reg = true;
GtkSettings * const settings = gtk_settings_get_default();
Q_ASSERT(settings);
if (!settings) {

View File

@ -1829,6 +1829,12 @@ void Utils::disableOriginalTitleBarFunctionalities(const WId windowId, const boo
void Utils::setQtDarkModeAwareEnabled(const bool enable, const bool pureQuick)
{
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
// We'll call QPA functions, so we have to ensure that the QGuiApplication
// instance has already been created and initialized, because the platform
// integration infrastructure is created and maintained by QGuiApplication.
if (!qGuiApp) {
return;
}
using App = QNativeInterface::Private::QWindowsApplication;
if (const auto app = qApp->nativeInterface<App>()) {
app->setDarkModeHandling([enable, pureQuick]() -> App::DarkModeHandling {