mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
Fix possible crash in MainWindow destructor.
This commit is contained in:
parent
d1cf43f9a4
commit
f1b0b60340
2 changed files with 35 additions and 30 deletions
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -767,12 +767,17 @@ void MainWindow::updateIconCounters() {
|
|||
}
|
||||
|
||||
void MainWindow::initHook() {
|
||||
auto platformInterface = QGuiApplication::platformNativeInterface();
|
||||
ps_hWnd = static_cast<HWND>(platformInterface->nativeResourceForWindow(QByteArrayLiteral("handle"), windowHandle()));
|
||||
if (const auto native = QGuiApplication::platformNativeInterface()) {
|
||||
ps_hWnd = static_cast<HWND>(native->nativeResourceForWindow(
|
||||
QByteArrayLiteral("handle"),
|
||||
windowHandle()));
|
||||
}
|
||||
if (!ps_hWnd) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ps_hWnd) return;
|
||||
|
||||
handleSessionNotification = (Dlls::WTSRegisterSessionNotification != nullptr) && (Dlls::WTSUnRegisterSessionNotification != nullptr);
|
||||
handleSessionNotification = (Dlls::WTSRegisterSessionNotification != nullptr)
|
||||
&& (Dlls::WTSUnRegisterSessionNotification != nullptr);
|
||||
if (handleSessionNotification) {
|
||||
Dlls::WTSRegisterSessionNotification(ps_hWnd, NOTIFY_FOR_THIS_SESSION);
|
||||
}
|
||||
|
@ -914,8 +919,12 @@ void MainWindow::psUpdateMargins() {
|
|||
_deltaLeft = _deltaTop = _deltaRight = _deltaBottom = 0;
|
||||
}
|
||||
|
||||
QPlatformNativeInterface *i = QGuiApplication::platformNativeInterface();
|
||||
i->setWindowProperty(windowHandle()->handle(), qsl("WindowsCustomMargins"), QVariant::fromValue<QMargins>(margins));
|
||||
if (const auto native = QGuiApplication::platformNativeInterface()) {
|
||||
native->setWindowProperty(
|
||||
windowHandle()->handle(),
|
||||
qsl("WindowsCustomMargins"),
|
||||
QVariant::fromValue<QMargins>(margins));
|
||||
}
|
||||
if (!_themeInited) {
|
||||
_themeInited = true;
|
||||
if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) {
|
||||
|
@ -953,13 +962,11 @@ void MainWindow::psDestroyIcons() {
|
|||
|
||||
MainWindow::~MainWindow() {
|
||||
if (handleSessionNotification) {
|
||||
QPlatformNativeInterface *i = QGuiApplication::platformNativeInterface();
|
||||
if (HWND hWnd = static_cast<HWND>(i->nativeResourceForWindow(QByteArrayLiteral("handle"), windowHandle()))) {
|
||||
Dlls::WTSUnRegisterSessionNotification(hWnd);
|
||||
}
|
||||
Dlls::WTSUnRegisterSessionNotification(ps_hWnd);
|
||||
}
|
||||
if (taskbarList) {
|
||||
taskbarList.Reset();
|
||||
}
|
||||
|
||||
if (taskbarList) taskbarList.Reset();
|
||||
|
||||
_shadowsWorking = false;
|
||||
if (ps_menu) DestroyMenu(ps_menu);
|
||||
|
|
Loading…
Add table
Reference in a new issue