mirror of https://github.com/procxx/kepka.git
				
				
				
			improved rpcClear() when deleting a complex RPCSender, clearing recent inline bots on logout
This commit is contained in:
		
							parent
							
								
									798f800913
								
							
						
					
					
						commit
						b678913da5
					
				| 
						 | 
				
			
			@ -1843,6 +1843,7 @@ namespace App {
 | 
			
		|||
		updatedPeers.clear();
 | 
			
		||||
		cSetSavedPeers(SavedPeers());
 | 
			
		||||
		cSetSavedPeersByTime(SavedPeersByTime());
 | 
			
		||||
		cSetRecentInlineBots(RecentInlineBots());
 | 
			
		||||
		for (PeersData::const_iterator i = peersData.cbegin(), e = peersData.cend(); i != e; ++i) {
 | 
			
		||||
			delete *i;
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -259,6 +259,11 @@ public:
 | 
			
		|||
 | 
			
		||||
	void updateNotifySettings(PeerData *peer);
 | 
			
		||||
 | 
			
		||||
	void rpcClear() override {
 | 
			
		||||
		_inner.rpcClear();
 | 
			
		||||
		RPCSender::rpcClear();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void notify_userIsContactChanged(UserData *user, bool fromThisApp);
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -569,12 +569,12 @@ public:
 | 
			
		|||
 | 
			
		||||
	bool contentOverlapped(const QRect &globalRect);
 | 
			
		||||
 | 
			
		||||
	void grabStart() {
 | 
			
		||||
	void grabStart() override {
 | 
			
		||||
		_sideShadow.hide();
 | 
			
		||||
		_inGrab = true;
 | 
			
		||||
		resizeEvent(0);
 | 
			
		||||
	}
 | 
			
		||||
	void grabFinish() {
 | 
			
		||||
	void grabFinish() override {
 | 
			
		||||
		_sideShadow.setVisible(!Adaptive::OneColumn());
 | 
			
		||||
		_inGrab = false;
 | 
			
		||||
		resizeEvent(0);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -428,11 +428,11 @@ void IntroWidget::keyPressEvent(QKeyEvent *e) {
 | 
			
		|||
void IntroWidget::updateAdaptiveLayout() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void IntroWidget::rpcInvalidate() {
 | 
			
		||||
	if (phone) phone->rpcInvalidate();
 | 
			
		||||
	if (code) code->rpcInvalidate();
 | 
			
		||||
	if (signup) signup->rpcInvalidate();
 | 
			
		||||
	if (pwdcheck) pwdcheck->rpcInvalidate();
 | 
			
		||||
void IntroWidget::rpcClear() {
 | 
			
		||||
	if (phone) phone->rpcClear();
 | 
			
		||||
	if (code) code->rpcClear();
 | 
			
		||||
	if (signup) signup->rpcClear();
 | 
			
		||||
	if (pwdcheck) pwdcheck->rpcClear();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
IntroWidget::~IntroWidget() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ class IntroPwdCheck;
 | 
			
		|||
class IntroStage;
 | 
			
		||||
class Text;
 | 
			
		||||
 | 
			
		||||
class IntroWidget : public TWidget {
 | 
			
		||||
class IntroWidget final : public TWidget {
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
| 
						 | 
				
			
			@ -71,7 +71,7 @@ public:
 | 
			
		|||
 | 
			
		||||
	void finish(const MTPUser &user, const QImage &photo = QImage());
 | 
			
		||||
 | 
			
		||||
	void rpcInvalidate();
 | 
			
		||||
	void rpcClear();
 | 
			
		||||
	void langChangeTo(int32 langId);
 | 
			
		||||
 | 
			
		||||
	~IntroWidget();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
 | 
			
		|||
#include "gui/flatinput.h"
 | 
			
		||||
#include "intro.h"
 | 
			
		||||
 | 
			
		||||
class IntroPwdCheck : public IntroStage, public RPCSender {
 | 
			
		||||
class IntroPwdCheck final : public IntroStage, public RPCSender {
 | 
			
		||||
	Q_OBJECT
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
 | 
			
		|||
*/
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <QtWidgets/QWidget>
 | 
			
		||||
#include "gui/flatbutton.h"
 | 
			
		||||
#include "intro.h"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2240,14 +2240,14 @@ void MainWidget::ui_showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool bac
 | 
			
		|||
			profile->hide();
 | 
			
		||||
			profile->clear();
 | 
			
		||||
			profile->deleteLater();
 | 
			
		||||
			profile->rpcInvalidate();
 | 
			
		||||
			profile->rpcClear();
 | 
			
		||||
			profile = 0;
 | 
			
		||||
		}
 | 
			
		||||
		if (overview) {
 | 
			
		||||
			overview->hide();
 | 
			
		||||
			overview->clear();
 | 
			
		||||
			overview->deleteLater();
 | 
			
		||||
			overview->rpcInvalidate();
 | 
			
		||||
			overview->rpcClear();
 | 
			
		||||
			overview = 0;
 | 
			
		||||
		}
 | 
			
		||||
		clearBotStartToken(_peerInStack);
 | 
			
		||||
| 
						 | 
				
			
			@ -2390,13 +2390,13 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool
 | 
			
		|||
		overview->hide();
 | 
			
		||||
		overview->clear();
 | 
			
		||||
		overview->deleteLater();
 | 
			
		||||
		overview->rpcInvalidate();
 | 
			
		||||
		overview->rpcClear();
 | 
			
		||||
	}
 | 
			
		||||
	if (profile) {
 | 
			
		||||
		profile->hide();
 | 
			
		||||
		profile->clear();
 | 
			
		||||
		profile->deleteLater();
 | 
			
		||||
		profile->rpcInvalidate();
 | 
			
		||||
		profile->rpcClear();
 | 
			
		||||
		profile = 0;
 | 
			
		||||
	}
 | 
			
		||||
	overview = new OverviewWidget(this, peer, type);
 | 
			
		||||
| 
						 | 
				
			
			@ -2446,14 +2446,14 @@ void MainWidget::showPeerProfile(PeerData *peer, bool back, int32 lastScrollTop)
 | 
			
		|||
		overview->hide();
 | 
			
		||||
		overview->clear();
 | 
			
		||||
		overview->deleteLater();
 | 
			
		||||
		overview->rpcInvalidate();
 | 
			
		||||
		overview->rpcClear();
 | 
			
		||||
		overview = 0;
 | 
			
		||||
	}
 | 
			
		||||
	if (profile) {
 | 
			
		||||
		profile->hide();
 | 
			
		||||
		profile->clear();
 | 
			
		||||
		profile->deleteLater();
 | 
			
		||||
		profile->rpcInvalidate();
 | 
			
		||||
		profile->rpcClear();
 | 
			
		||||
	}
 | 
			
		||||
	profile = new ProfileWidget(this, peer);
 | 
			
		||||
	_topBar.show();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,10 +59,10 @@ public:
 | 
			
		|||
 | 
			
		||||
	FlatButton *mediaTypeButton();
 | 
			
		||||
 | 
			
		||||
	void grabStart() {
 | 
			
		||||
	void grabStart() override {
 | 
			
		||||
		_sideShadow.hide();
 | 
			
		||||
	}
 | 
			
		||||
	void grabFinish() {
 | 
			
		||||
	void grabFinish() override {
 | 
			
		||||
		_sideShadow.setVisible(!Adaptive::OneColumn());
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -417,6 +417,15 @@ public:
 | 
			
		|||
	QPixmap grabTopBar();
 | 
			
		||||
	QPixmap grabInner();
 | 
			
		||||
 | 
			
		||||
	void rpcClear() override {
 | 
			
		||||
		history.rpcClear();
 | 
			
		||||
		dialogs.rpcClear();
 | 
			
		||||
		if (profile) profile->rpcClear();
 | 
			
		||||
		if (overview) overview->rpcClear();
 | 
			
		||||
		if (_api) _api->rpcClear();
 | 
			
		||||
		RPCSender::rpcClear();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	bool isItemVisible(HistoryItem *item);
 | 
			
		||||
 | 
			
		||||
	void ui_repaintHistoryItem(const HistoryItem *item);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -154,7 +154,7 @@ namespace {
 | 
			
		|||
	bool onErrorDefault(mtpRequestId requestId, const RPCError &error) {
 | 
			
		||||
		const QString &err(error.type());
 | 
			
		||||
		int32 code = error.code();
 | 
			
		||||
		if (!mtpIsFlood(error)) {
 | 
			
		||||
		if (!mtpIsFlood(error) && err != qsl("AUTH_KEY_UNREGISTERED")) {
 | 
			
		||||
			int breakpoint = 0;
 | 
			
		||||
		}
 | 
			
		||||
		bool badGuestDC = (code == 400) && (err == qsl("FILE_ID_INVALID"));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -236,7 +236,7 @@ public:
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	virtual void stop() {
 | 
			
		||||
		rpcInvalidate();
 | 
			
		||||
		rpcClear();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	~mtpFileLoader();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -791,6 +791,16 @@ public:
 | 
			
		|||
		return RPCFailHandlerPtr(new RPCBindedFailHandlerOwnedNo<T, TReceiver>(b, static_cast<TReceiver*>(this), onFail));
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	virtual void rpcClear() {
 | 
			
		||||
		rpcInvalidate();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	virtual ~RPCSender() {
 | 
			
		||||
		rpcInvalidate();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
 | 
			
		||||
	void rpcInvalidate() {
 | 
			
		||||
		for (DoneHandlers::iterator i = _rpcDoneHandlers.begin(), e = _rpcDoneHandlers.end(); i != e; ++i) {
 | 
			
		||||
			(*i)->invalidate();
 | 
			
		||||
| 
						 | 
				
			
			@ -802,10 +812,6 @@ public:
 | 
			
		|||
		_rpcFailHandlers.clear();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	~RPCSender() {
 | 
			
		||||
		rpcInvalidate();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef void (*MTPStateChangedHandler)(int32 dcId, int32 state);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -289,16 +289,20 @@ public:
 | 
			
		|||
 | 
			
		||||
	void updateAfterDrag();
 | 
			
		||||
 | 
			
		||||
	void grabStart() {
 | 
			
		||||
	void grabStart() override {
 | 
			
		||||
		_sideShadow.hide();
 | 
			
		||||
		_inGrab = true;
 | 
			
		||||
		resizeEvent(0);
 | 
			
		||||
	}
 | 
			
		||||
	void grabFinish() {
 | 
			
		||||
	void grabFinish() override {
 | 
			
		||||
		_sideShadow.setVisible(!Adaptive::OneColumn());
 | 
			
		||||
		_inGrab = false;
 | 
			
		||||
		resizeEvent(0);
 | 
			
		||||
	}
 | 
			
		||||
	void rpcClear() override {
 | 
			
		||||
		_inner.rpcClear();
 | 
			
		||||
		RPCSender::rpcClear();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void ui_repaintHistoryItem(const HistoryItem *item);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -247,16 +247,20 @@ public:
 | 
			
		|||
	void mediaOverviewUpdated(PeerData *peer, MediaOverviewType type);
 | 
			
		||||
	void updateAdaptiveLayout();
 | 
			
		||||
 | 
			
		||||
	void grabStart() {
 | 
			
		||||
	void grabStart() override {
 | 
			
		||||
		_sideShadow.hide();
 | 
			
		||||
		_inGrab = true;
 | 
			
		||||
		resizeEvent(0);
 | 
			
		||||
	}
 | 
			
		||||
	void grabFinish() {
 | 
			
		||||
	void grabFinish() override {
 | 
			
		||||
		_sideShadow.setVisible(!Adaptive::OneColumn());
 | 
			
		||||
		_inGrab = false;
 | 
			
		||||
		resizeEvent(0);
 | 
			
		||||
	}
 | 
			
		||||
	void rpcClear() override {
 | 
			
		||||
		_inner.rpcClear();
 | 
			
		||||
		RPCSender::rpcClear();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	void clear();
 | 
			
		||||
	~ProfileWidget();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1945,8 +1945,8 @@ void SettingsWidget::updateConnectionType() {
 | 
			
		|||
	_inner.updateConnectionType();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SettingsWidget::rpcInvalidate() {
 | 
			
		||||
	_inner.rpcInvalidate();
 | 
			
		||||
void SettingsWidget::rpcClear() {
 | 
			
		||||
	_inner.rpcClear();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void SettingsWidget::usernameChanged() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -330,7 +330,7 @@ public:
 | 
			
		|||
 | 
			
		||||
	void updateDisplayNotify();
 | 
			
		||||
 | 
			
		||||
	void rpcInvalidate();
 | 
			
		||||
	void rpcClear();
 | 
			
		||||
	void usernameChanged();
 | 
			
		||||
 | 
			
		||||
	void setInnerFocus();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1203,7 +1203,7 @@ bool DocumentData::loaded(bool check) const {
 | 
			
		|||
	if (loading() && _loader->done()) {
 | 
			
		||||
		if (_loader->fileType() == mtpc_storage_fileUnknown) {
 | 
			
		||||
			_loader->deleteLater();
 | 
			
		||||
			_loader->rpcInvalidate();
 | 
			
		||||
			_loader->rpcClear();
 | 
			
		||||
			_loader = CancelledMtpFileLoader;
 | 
			
		||||
		} else {
 | 
			
		||||
			DocumentData *that = const_cast<DocumentData*>(this);
 | 
			
		||||
| 
						 | 
				
			
			@ -1214,7 +1214,7 @@ bool DocumentData::loaded(bool check) const {
 | 
			
		|||
			}
 | 
			
		||||
 | 
			
		||||
			_loader->deleteLater();
 | 
			
		||||
			_loader->rpcInvalidate();
 | 
			
		||||
			_loader->rpcClear();
 | 
			
		||||
			_loader = 0;
 | 
			
		||||
		}
 | 
			
		||||
		notifyLayoutChanged();
 | 
			
		||||
| 
						 | 
				
			
			@ -1296,7 +1296,7 @@ void DocumentData::cancel() {
 | 
			
		|||
	if (l) {
 | 
			
		||||
		l->cancel();
 | 
			
		||||
		l->deleteLater();
 | 
			
		||||
		l->rpcInvalidate();
 | 
			
		||||
		l->rpcClear();
 | 
			
		||||
 | 
			
		||||
		notifyLayoutChanged();
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -504,21 +504,21 @@ void Window::clearWidgets() {
 | 
			
		|||
		settings->stop_show();
 | 
			
		||||
		settings->hide();
 | 
			
		||||
		settings->deleteLater();
 | 
			
		||||
		settings->rpcInvalidate();
 | 
			
		||||
		settings->rpcClear();
 | 
			
		||||
		settings = 0;
 | 
			
		||||
	}
 | 
			
		||||
	if (main) {
 | 
			
		||||
		main->animStop_show();
 | 
			
		||||
		main->hide();
 | 
			
		||||
		main->deleteLater();
 | 
			
		||||
		main->rpcInvalidate();
 | 
			
		||||
		main->rpcClear();
 | 
			
		||||
		main = 0;
 | 
			
		||||
	}
 | 
			
		||||
	if (intro) {
 | 
			
		||||
		intro->stop_show();
 | 
			
		||||
		intro->hide();
 | 
			
		||||
		intro->deleteLater();
 | 
			
		||||
		intro->rpcInvalidate();
 | 
			
		||||
		intro->rpcClear();
 | 
			
		||||
		intro = 0;
 | 
			
		||||
	}
 | 
			
		||||
	title->updateBackButton();
 | 
			
		||||
| 
						 | 
				
			
			@ -724,7 +724,7 @@ void Window::hideSettings(bool fast) {
 | 
			
		|||
		settings->stop_show();
 | 
			
		||||
		settings->hide();
 | 
			
		||||
		settings->deleteLater();
 | 
			
		||||
		settings->rpcInvalidate();
 | 
			
		||||
		settings->rpcClear();
 | 
			
		||||
		settings = 0;
 | 
			
		||||
		if (intro) {
 | 
			
		||||
			intro->show();
 | 
			
		||||
| 
						 | 
				
			
			@ -737,7 +737,7 @@ void Window::hideSettings(bool fast) {
 | 
			
		|||
		settings->stop_show();
 | 
			
		||||
		settings->hide();
 | 
			
		||||
		settings->deleteLater();
 | 
			
		||||
		settings->rpcInvalidate();
 | 
			
		||||
		settings->rpcClear();
 | 
			
		||||
		settings = 0;
 | 
			
		||||
		if (intro) {
 | 
			
		||||
			intro->animShow(bg, true);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue