From 7fc418e5841a1633f651e08a34ccd2123ba6e0db Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Tue, 31 Mar 2009 00:53:20 +0200 Subject: [PATCH] fixing weird behavior of backlog fetching --- src/client/bufferviewoverlay.cpp | 54 +++++++++++++++++++++++++++++++- src/client/bufferviewoverlay.h | 18 +++++------ src/client/client.cpp | 11 +++---- src/client/client.h | 3 +- 4 files changed, 68 insertions(+), 18 deletions(-) diff --git a/src/client/bufferviewoverlay.cpp b/src/client/bufferviewoverlay.cpp index 66dec133..cba8035a 100644 --- a/src/client/bufferviewoverlay.cpp +++ b/src/client/bufferviewoverlay.cpp @@ -108,6 +108,9 @@ void BufferViewOverlay::update() { } void BufferViewOverlay::updateHelper() { + if(!_aboutToUpdate) + return; + bool changed = false; bool addBuffersAutomatically = false; @@ -162,6 +165,9 @@ void BufferViewOverlay::updateHelper() { if(minimumActivity == -1 || config->minimumActivity() < minimumActivity) minimumActivity = config->minimumActivity(); } + QSet availableBuffers = Client::networkModel()->allBufferIds().toSet(); + buffers.intersect(availableBuffers); + tempRemovedBuffers.intersect(availableBuffers); } changed |= (addBuffersAutomatically != _addBuffersAutomatically); @@ -182,6 +188,8 @@ void BufferViewOverlay::updateHelper() { _removedBuffers = removedBuffers; _tempRemovedBuffers = tempRemovedBuffers; + _aboutToUpdate = false; + if(changed) emit hasChanged(); } @@ -189,6 +197,50 @@ void BufferViewOverlay::updateHelper() { void BufferViewOverlay::customEvent(QEvent *event) { if(event->type() == _updateEventId) { updateHelper(); - _aboutToUpdate = false; } } + +bool BufferViewOverlay::allNetworks() { + updateHelper(); + return _networkIds.contains(NetworkId()); +} + +const QSet &BufferViewOverlay::networkIds() { + updateHelper(); + return _networkIds; +} + +const QSet &BufferViewOverlay::bufferIds() { + updateHelper(); + return _buffers; +} + +const QSet &BufferViewOverlay::removedBufferIds() { + updateHelper(); + return _removedBuffers; +} + +const QSet &BufferViewOverlay::tempRemovedBufferIds() { + updateHelper(); + return _tempRemovedBuffers; +} + +bool BufferViewOverlay::addBuffersAutomatically() { + updateHelper(); + return _addBuffersAutomatically; +} + +bool BufferViewOverlay::hideInactiveBuffers() { + updateHelper(); + return _hideInactiveBuffers; +} + +int BufferViewOverlay::allowedBufferTypes() { + updateHelper(); + return _allowedBufferTypes; +} + +int BufferViewOverlay::minimumActivity() { + updateHelper(); + return _minimumActivity; +} diff --git a/src/client/bufferviewoverlay.h b/src/client/bufferviewoverlay.h index 483a3302..70fb9276 100644 --- a/src/client/bufferviewoverlay.h +++ b/src/client/bufferviewoverlay.h @@ -34,17 +34,17 @@ class BufferViewOverlay : public QObject { public: BufferViewOverlay(QObject *parent = 0); - inline bool allNetworks() const { return _networkIds.contains(NetworkId()); } + bool allNetworks(); - inline const QSet &networkIds() const { return _networkIds; } - inline const QSet &bufferIds() const { return _buffers; } - inline const QSet &removedBufferIds() const { return _removedBuffers; } - inline const QSet &tempRemovedBufferIds() const { return _tempRemovedBuffers; } + const QSet &networkIds(); + const QSet &bufferIds(); + const QSet &removedBufferIds(); + const QSet &tempRemovedBufferIds(); - inline bool addBuffersAutomatically() const { return _addBuffersAutomatically; } - inline bool hideInactiveBuffers() const { return _hideInactiveBuffers; } - inline int allowedBufferTypes() const { return _allowedBufferTypes; } - inline int minimumActivity() const { return _minimumActivity; } + bool addBuffersAutomatically(); + bool hideInactiveBuffers(); + int allowedBufferTypes(); + int minimumActivity(); public slots: void addView(int viewId); diff --git a/src/client/client.cpp b/src/client/client.cpp index d04e258d..741388c1 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -97,7 +97,6 @@ Client::Client(QObject *parent) _debugLog(&_debugLogBuffer) { _signalProxy->synchronize(_ircListHelper); - connect(this, SIGNAL(requestInitialBacklog()), _backlogManager, SLOT(requestInitialBacklog()), Qt::QueuedConnection); } Client::~Client() { @@ -323,7 +322,7 @@ void Client::setSyncedToCore() { Q_ASSERT(!_bufferViewManager); _bufferViewManager = new ClientBufferViewManager(signalProxy(), this); connect(bufferViewManager(), SIGNAL(initDone()), this, SLOT(createDefaultBufferView())); - connect(bufferViewManager(), SIGNAL(viewsInitialized()), this, SLOT(requestInitialBacklogBarrier())); + connect(bufferViewManager(), SIGNAL(viewsInitialized()), this, SLOT(requestInitialBacklog())); // create AliasManager Q_ASSERT(!_aliasManager); @@ -336,16 +335,16 @@ void Client::setSyncedToCore() { emit coreConnectionStateChanged(true); } -void Client::requestInitialBacklogBarrier() { +void Client::requestInitialBacklog() { // usually it _should_ take longer until the bufferViews are initialized, so that's what // triggers this slot. But we have to make sure that we know all buffers yet. // so we check the BufferSyncer and in case it wasn't initialized we wait for that instead if(!bufferSyncer()->isInitialized()) { - disconnect(bufferViewManager(), SIGNAL(viewsInitialized()), this, SLOT(requestInitialBacklogBarrier())); - connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklogBarrier())); + disconnect(bufferViewManager(), SIGNAL(viewsInitialized()), this, SLOT(requestInitialBacklog())); + connect(bufferSyncer(), SIGNAL(initDone()), this, SLOT(requestInitialBacklog())); return; } - emit requestInitialBacklog(); + _backlogManager->requestInitialBacklog(); } void Client::createDefaultBufferView() { diff --git a/src/client/client.h b/src/client/client.h index 0c9922a4..47877311 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -131,7 +131,6 @@ public: static inline void registerClientSyncer(ClientSyncer *syncer) { emit instance()->newClientSyncer(syncer); } signals: - void requestInitialBacklog(); void requestNetworkStates(); void showConfigWizard(const QVariantMap &coredata); @@ -189,7 +188,7 @@ private slots: void setConnectedToCore(AccountId id, QIODevice *socket = 0); void setSyncedToCore(); - void requestInitialBacklogBarrier(); + void requestInitialBacklog(); void createDefaultBufferView(); void sendBufferedUserInput(); -- 2.20.1