mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Remove Q_OBJECT dependency from ApiWrap.
Also remove it from SingleDelayedCall -> SingleQueuedInvocation.
This commit is contained in:
@@ -23,7 +23,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||
#include "mainwidget.h"
|
||||
#include "storage/localstorage.h"
|
||||
#include "platform/platform_specific.h"
|
||||
#include "messenger.h"
|
||||
#include "auth_session.h"
|
||||
|
||||
namespace Images {
|
||||
namespace {
|
||||
@@ -858,7 +858,7 @@ void RemoteImage::doCheckload() const {
|
||||
void RemoteImage::destroyLoaderDelayed(FileLoader *newValue) const {
|
||||
_loader->stop();
|
||||
auto loader = std::unique_ptr<FileLoader>(std::exchange(_loader, newValue));
|
||||
Messenger::Instance().delayedDestroyLoader(std::move(loader));
|
||||
AuthSession::Current().downloader().delayedDestroyLoader(std::move(loader));
|
||||
}
|
||||
|
||||
void RemoteImage::loadLocal() {
|
||||
@@ -959,7 +959,7 @@ void RemoteImage::cancel() {
|
||||
auto loader = std::exchange(_loader, CancelledFileLoader);
|
||||
loader->cancel();
|
||||
loader->stop();
|
||||
Messenger::Instance().delayedDestroyLoader(std::unique_ptr<FileLoader>(loader));
|
||||
AuthSession::Current().downloader().delayedDestroyLoader(std::unique_ptr<FileLoader>(loader));
|
||||
}
|
||||
|
||||
float64 RemoteImage::progress() const {
|
||||
|
@@ -328,28 +328,23 @@ void myEnsureResized(QWidget *target);
|
||||
QPixmap myGrab(TWidget *target, QRect rect = QRect(), QColor bg = QColor(255, 255, 255, 0));
|
||||
QImage myGrabImage(TWidget *target, QRect rect = QRect(), QColor bg = QColor(255, 255, 255, 0));
|
||||
|
||||
class SingleDelayedCall : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
class SingleQueuedInvokation : public QObject {
|
||||
public:
|
||||
SingleDelayedCall(QObject *parent, const char *member) : QObject(parent), _member(member) {
|
||||
SingleQueuedInvokation(base::lambda<void()> callback) : _callback(callback) {
|
||||
}
|
||||
void call() {
|
||||
if (_pending.testAndSetOrdered(0, 1)) {
|
||||
QMetaObject::invokeMethod(this, "makeDelayedCall", Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
private slots:
|
||||
void makeDelayedCall() {
|
||||
if (_pending.testAndSetOrdered(1, 0)) {
|
||||
QMetaObject::invokeMethod(parent(), _member);
|
||||
if (_pending.testAndSetAcquire(0, 1)) {
|
||||
InvokeQueued(this, [this] {
|
||||
if (_pending.testAndSetRelease(1, 0)) {
|
||||
_callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
base::lambda<void()> _callback;
|
||||
QAtomicInt _pending = { 0 };
|
||||
const char *_member;
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user