2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Fix possible crash in MainWindow destructor.

This commit is contained in:
John Preston
2019-03-21 22:21:23 +04:00
parent d1cf43f9a4
commit f1b0b60340
2 changed files with 35 additions and 30 deletions

View File

@@ -261,24 +261,22 @@ void finish() {
}
bool TranslucentWindowsSupported(QPoint globalPosition) {
if (auto app = static_cast<QGuiApplication*>(QCoreApplication::instance())) {
if (auto native = app->platformNativeInterface()) {
if (auto desktop = QApplication::desktop()) {
auto index = desktop->screenNumber(globalPosition);
auto screens = QGuiApplication::screens();
if (auto screen = (index >= 0 && index < screens.size()) ? screens[index] : QGuiApplication::primaryScreen()) {
if (native->nativeResourceForScreen(QByteArray("compositingEnabled"), screen)) {
return true;
}
static OrderedSet<int> WarnedAbout;
if (!WarnedAbout.contains(index)) {
WarnedAbout.insert(index);
LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
}
} else {
LOG(("WARNING: Could not get screen for index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
if (const auto native = QGuiApplication::platformNativeInterface()) {
if (const auto desktop = QApplication::desktop()) {
const auto index = desktop->screenNumber(globalPosition);
const auto screens = QGuiApplication::screens();
if (const auto screen = (index >= 0 && index < screens.size()) ? screens[index] : QGuiApplication::primaryScreen()) {
if (native->nativeResourceForScreen(QByteArray("compositingEnabled"), screen)) {
return true;
}
static auto WarnedAbout = base::flat_set<int>();
if (!WarnedAbout.contains(index)) {
WarnedAbout.insert(index);
LOG(("WARNING: Compositing is disabled for screen index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
}
} else {
LOG(("WARNING: Could not get screen for index %1 (for position %2,%3)").arg(index).arg(globalPosition.x()).arg(globalPosition.y()));
}
}
}