2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 22:46:10 +00:00

Add Ui::PostponeCall() on return to event loop.

This commit is contained in:
John Preston
2018-12-12 12:59:51 +04:00
parent a167a8587b
commit 89cf733d24
5 changed files with 95 additions and 2 deletions

View File

@@ -15,7 +15,7 @@ class UpdateChecker;
bool InternalPassportLink(const QString &url);
bool StartUrlRequiresActivate(const QString &url);
class Application : public QApplication {
class Application : public QApplication, private QAbstractNativeEventFilter {
Q_OBJECT
public:
@@ -26,6 +26,9 @@ public:
void createMessenger();
void refreshGlobalProxy();
void postponeCall(FnMut<void()> &&callable);
bool notify(QObject *receiver, QEvent *e) override;
~Application();
signals:
@@ -50,6 +53,23 @@ private:
typedef QPair<QLocalSocket*, QByteArray> LocalClient;
typedef QList<LocalClient> LocalClients;
struct PostponedCall {
int loopNestingLevel = 0;
FnMut<void()> callable;
};
bool nativeEventFilter(
const QByteArray &eventType,
void *message,
long *result) override;
void processPostponedCalls(int level);
const Qt::HANDLE _mainThreadId = nullptr;
int _eventNestingLevel = 0;
int _loopNestingLevel = 0;
std::vector<int> _previousLoopNestingLevels;
std::vector<PostponedCall> _postponedCalls;
not_null<Core::Launcher*> _launcher;
std::unique_ptr<Messenger> _messengerInstance;