From e2e5327ccade6baf433598b1b25dfe99cb360028 Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Mon, 4 Feb 2008 20:28:56 +0000 Subject: [PATCH] fixed a bug in IrcChannel. Upgrade is strongly advised! Distclean as usual. --- src/client/networkmodel.cpp | 20 +++++++++++++++----- src/client/networkmodel.h | 4 +++- src/client/treemodel.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/client/treemodel.h | 6 +++++- src/common/ircchannel.cpp | 2 ++ src/common/ircuser.cpp | 5 ++++- src/common/network.cpp | 1 + version.inc | 6 +++--- 8 files changed, 70 insertions(+), 11 deletions(-) diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index 61b269ff..f40b7268 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -60,7 +60,7 @@ const BufferInfo &BufferItem::bufferInfo() const { } quint64 BufferItem::id() const { - return bufferInfo().bufferId().toInt(); + return qHash(bufferInfo().bufferId()); } bool BufferItem::isStatusBuffer() const { @@ -308,7 +308,7 @@ QVariant NetworkItem::data(int column, int role) const { } quint64 NetworkItem::id() const { - return _networkId.toInt(); + return qHash(_networkId); } void NetworkItem::setActive(bool connected) { @@ -470,7 +470,17 @@ IrcUserItem::IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent) } QString IrcUserItem::nickName() const { - return _ircUser->nick(); + if(_ircUser) + return _ircUser->nick(); + else + return QString(); +} + +bool IrcUserItem::isActive() const { + if(_ircUser) + return !_ircUser->isAway(); + else + return false; } IrcUser *IrcUserItem::ircUser() { @@ -478,13 +488,13 @@ IrcUser *IrcUserItem::ircUser() { } quint64 IrcUserItem::id() const { - return (quint64)_ircUser; + return qHash((IrcUser *)_ircUser); } QVariant IrcUserItem::data(int column, int role) const { switch(role) { case NetworkModel::ItemActiveRole: - return !_ircUser->isAway(); + return isActive(); case NetworkModel::ItemTypeRole: return NetworkModel::IrcUserItemType; case NetworkModel::BufferIdRole: diff --git a/src/client/networkmodel.h b/src/client/networkmodel.h index 959d89a4..63eb5696 100644 --- a/src/client/networkmodel.h +++ b/src/client/networkmodel.h @@ -191,6 +191,8 @@ public: IrcUserItem(IrcUser *ircUser, AbstractTreeItem *parent); QString nickName() const; + bool isActive() const; + IrcUser *ircUser(); virtual quint64 id() const; virtual QVariant data(int column, int role) const; @@ -200,7 +202,7 @@ private slots: void setNick(QString newNick); private: - IrcUser *_ircUser; + QPointer _ircUser; }; diff --git a/src/client/treemodel.cpp b/src/client/treemodel.cpp index 80e7630b..0d35ef64 100644 --- a/src/client/treemodel.cpp +++ b/src/client/treemodel.cpp @@ -311,6 +311,17 @@ TreeModel::TreeModel(const QList &data, QObject *parent) { rootItem = new SimpleTreeItem(data, 0); connectItem(rootItem); + + /* + connect(this, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), + this, SLOT(debug_rowsAboutToBeInserted(const QModelIndex &, int, int))); + connect(this, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), + this, SLOT(debug_rowsAboutToBeRemoved(const QModelIndex &, int, int))); + connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), + this, SLOT(debug_rowsInserted(const QModelIndex &, int, int))); + connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), + this, SLOT(debug_rowsRemoved(const QModelIndex &, int, int))); + */ } TreeModel::~TreeModel() { @@ -541,3 +552,29 @@ void TreeModel::endRemoveChilds() { void TreeModel::clear() { rootItem->removeAllChilds(); } + +void TreeModel::debug_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end) { + qDebug() << "debug_rowsAboutToBeInserted" << parent << parent.internalPointer() << parent.data().toString() << rowCount(parent) << start << end; +} + +void TreeModel::debug_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end) { + qDebug() << "debug_rowsAboutToBeRemoved" << parent << parent.internalPointer() << parent.data().toString() << rowCount(parent) << start << end; + QModelIndex child; + for(int i = start; i <= end; i++) { + child = parent.child(i, 0); + qDebug() << " " << child << child.data().toString(); // << static_cast(parent.child(i, 0).internalPointer())->id(); + } +} + +void TreeModel::debug_rowsInserted(const QModelIndex &parent, int start, int end) { + qDebug() << "debug_rowsInserted" << parent << parent.internalPointer() << parent.data().toString() << rowCount(parent) << start << end; + QModelIndex child; + for(int i = start; i <= end; i++) { + child = parent.child(i, 0); + qDebug() << " " << child << child.data().toString(); // << static_cast(parent.child(i, 0).internalPointer())->id(); + } +} + +void TreeModel::debug_rowsRemoved(const QModelIndex &parent, int start, int end) { + qDebug() << "debug_rowsRemoved" << parent << parent.internalPointer() << parent.data().toString() << rowCount(parent) << start << end; +} diff --git a/src/client/treemodel.h b/src/client/treemodel.h index 55dafac5..6f2575c0 100644 --- a/src/client/treemodel.h +++ b/src/client/treemodel.h @@ -188,8 +188,12 @@ private: }; ChildStatus _childStatus; int _aboutToRemoveOrInsert; - // QLinkedList _childStatus; +private slots: + void debug_rowsAboutToBeInserted(const QModelIndex &parent, int start, int end); + void debug_rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end); + void debug_rowsInserted(const QModelIndex &parent, int start, int end); + void debug_rowsRemoved(const QModelIndex &parent, int start, int end); }; #endif diff --git a/src/common/ircchannel.cpp b/src/common/ircchannel.cpp index e6c809f0..38959aa9 100644 --- a/src/common/ircchannel.cpp +++ b/src/common/ircchannel.cpp @@ -164,6 +164,7 @@ void IrcChannel::part(IrcUser *ircuser) { //qDebug() << "PART" << name() << ircuser->nick() << ircUsers().count(); // if you wonder why there is no counterpart to ircUserParted: // the joines are propagted by the ircuser. the signal ircUserParted is only for convenience + disconnect(ircuser, 0, this, 0); emit ircUserParted(ircuser); if(network->isMe(ircuser)) deleteLater(); @@ -241,6 +242,7 @@ void IrcChannel::initSetUserModes(const QVariantMap &usermodes) { } void IrcChannel::ircUserDestroyed() { + qDebug() << "IrcChannel::ircUserDestroyed()"; IrcUser *ircUser = static_cast(sender()); Q_ASSERT(ircUser); _userModes.remove(ircUser); diff --git a/src/common/ircuser.cpp b/src/common/ircuser.cpp index 704934b7..99f2ae31 100644 --- a/src/common/ircuser.cpp +++ b/src/common/ircuser.cpp @@ -49,7 +49,10 @@ IrcUser::IrcUser(const QString &hostmask, Network *network) } IrcUser::~IrcUser() { - //qDebug() << nick() << "destroyed."; + QList channels = _channels.toList(); + foreach(IrcChannel *channel, channels) { + partChannel(channel); + } } // ==================== diff --git a/src/common/network.cpp b/src/common/network.cpp index d3ecab56..8f5680be 100644 --- a/src/common/network.cpp +++ b/src/common/network.cpp @@ -236,6 +236,7 @@ void Network::removeIrcUser(IrcUser *ircuser) { return; _ircUsers.remove(nick); + disconnect(ircuser, 0, this, 0); emit ircUserRemoved(nick); emit ircUserRemoved(ircuser); ircuser->deleteLater(); diff --git a/version.inc b/version.inc index d6629d4b..c0abd2d1 100644 --- a/version.inc +++ b/version.inc @@ -5,14 +5,14 @@ quasselVersion = "0.2.0-pre"; quasselDate = "2008-02-04"; - quasselBuild = 455; + quasselBuild = 456; //! Minimum client build number the core needs - clientBuildNeeded = 437; + clientBuildNeeded = 456; clientVersionNeeded = quasselVersion; //! Minimum core build number the client needs - coreBuildNeeded = 437; + coreBuildNeeded = 456; coreVersionNeeded = quasselVersion; } -- 2.20.1