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:
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user