mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-24 09:16:57 +00:00
Fix crash with event loop nesting tracking.
This commit is contained in:
parent
cc8f4aa24f
commit
7cfb122dea
@ -675,9 +675,13 @@ void MainWindow::showFromTray(QSystemTrayIcon::ActivationReason reason) {
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::toggleTray(QSystemTrayIcon::ActivationReason reason) {
|
||||
void MainWindow::handleTrayIconActication(
|
||||
QSystemTrayIcon::ActivationReason reason) {
|
||||
updateIsActive(0);
|
||||
if ((cPlatform() == dbipMac || cPlatform() == dbipMacOld) && isActive()) return;
|
||||
if ((cPlatform() == dbipMac || cPlatform() == dbipMacOld)
|
||||
&& isActive()) {
|
||||
return;
|
||||
}
|
||||
if (reason == QSystemTrayIcon::Context) {
|
||||
updateTrayMenu(true);
|
||||
QTimer::singleShot(1, this, SLOT(psShowTrayMenu()));
|
||||
|
@ -132,7 +132,6 @@ public slots:
|
||||
|
||||
void quitFromTray();
|
||||
void showFromTray(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Unknown);
|
||||
void toggleTray(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Unknown);
|
||||
void toggleDisplayNotifyFromTray();
|
||||
|
||||
void onClearFinished(int task, void *manager);
|
||||
@ -150,6 +149,9 @@ signals:
|
||||
private:
|
||||
[[nodiscard]] bool skipTrayClick() const;
|
||||
|
||||
void handleTrayIconActication(
|
||||
QSystemTrayIcon::ActivationReason reason) override;
|
||||
|
||||
void hideMediaPreview();
|
||||
void ensureLayerCreated();
|
||||
void destroyLayer();
|
||||
|
@ -268,9 +268,6 @@ void MainWindow::psSetupTrayIcon() {
|
||||
}
|
||||
trayIcon->setIcon(icon);
|
||||
|
||||
trayIcon->setToolTip(str_const_toString(AppName));
|
||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
|
||||
|
||||
// This is very important for native notifications via libnotify!
|
||||
// Some notification servers compose several notifications with a "Reply"
|
||||
// action into one and after that a click on "Reply" button does not call
|
||||
@ -278,7 +275,7 @@ void MainWindow::psSetupTrayIcon() {
|
||||
// just ignores ibus messages, but Qt tray icon at least emits this signal.
|
||||
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
|
||||
|
||||
App::wnd()->updateTrayMenu();
|
||||
attachToTrayIcon(trayIcon);
|
||||
}
|
||||
updateIconCounters();
|
||||
|
||||
|
@ -450,9 +450,7 @@ void MainWindow::psSetupTrayIcon() {
|
||||
icon.addPixmap(QPixmap::fromImage(psTrayIcon(true), Qt::ColorOnly), QIcon::Selected);
|
||||
|
||||
trayIcon->setIcon(icon);
|
||||
trayIcon->setToolTip(str_const_toString(AppName));
|
||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
|
||||
App::wnd()->updateTrayMenu();
|
||||
attachToTrayIcon(trayIcon);
|
||||
}
|
||||
updateIconCounters();
|
||||
|
||||
|
@ -667,10 +667,8 @@ void MainWindow::psSetupTrayIcon() {
|
||||
auto icon = QIcon(App::pixmapFromImageInPlace(Core::App().logoNoMargin()));
|
||||
|
||||
trayIcon->setIcon(icon);
|
||||
trayIcon->setToolTip(str_const_toString(AppName));
|
||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(toggleTray(QSystemTrayIcon::ActivationReason)), Qt::UniqueConnection);
|
||||
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(showFromTray()));
|
||||
App::wnd()->updateTrayMenu();
|
||||
attachToTrayIcon(trayIcon);
|
||||
}
|
||||
updateIconCounters();
|
||||
|
||||
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "core/click_handler_types.h"
|
||||
#include "core/application.h"
|
||||
#include "core/sandbox.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "data/data_session.h"
|
||||
#include "auth_session.h"
|
||||
@ -406,6 +407,17 @@ void MainWindow::setPositionInited() {
|
||||
_positionInited = true;
|
||||
}
|
||||
|
||||
void MainWindow::attachToTrayIcon(not_null<QSystemTrayIcon*> icon) {
|
||||
icon->setToolTip(str_const_toString(AppName));
|
||||
connect(icon, &QSystemTrayIcon::activated, this, [=](
|
||||
QSystemTrayIcon::ActivationReason reason) {
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||
handleTrayIconActication(reason);
|
||||
});
|
||||
});
|
||||
App::wnd()->updateTrayMenu();
|
||||
}
|
||||
|
||||
void MainWindow::resizeEvent(QResizeEvent *e) {
|
||||
updateControlsGeometry();
|
||||
}
|
||||
|
@ -143,6 +143,9 @@ protected:
|
||||
virtual int32 screenNameChecksum(const QString &name) const;
|
||||
|
||||
void setPositionInited();
|
||||
void attachToTrayIcon(not_null<QSystemTrayIcon*> icon);
|
||||
virtual void handleTrayIconActication(
|
||||
QSystemTrayIcon::ActivationReason reason) = 0;
|
||||
|
||||
private:
|
||||
void checkAuthSession();
|
||||
|
Loading…
Reference in New Issue
Block a user