From: Manuel Nickschas Date: Fri, 10 Aug 2007 18:06:10 +0000 (+0000) Subject: Fixed disconnect from Core. Dis- and reconnecting should now work as expected. X-Git-Tag: 0.1.0~168 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=4bdda41a706b963c0163d38764acb3ffea52f256 Fixed disconnect from Core. Dis- and reconnecting should now work as expected. I had to add some dirty hack in BufferTreeModel for this -> EgS, please check :) Oh, and I removed the reaaally obsolete ircwidget.ui from svn. This has been rotting there for months. --- diff --git a/Quassel.kdevelop.filelist b/Quassel.kdevelop.filelist index e9088246..78be97ae 100644 --- a/Quassel.kdevelop.filelist +++ b/Quassel.kdevelop.filelist @@ -90,7 +90,6 @@ src/qtgui/ui/coreconnectdlg.ui src/qtgui/ui/coresettingspage.ui src/qtgui/ui/identitiesdlg.ui src/qtgui/ui/identitieseditdlg.ui -src/qtgui/ui/ircwidget.ui src/qtgui/ui/mainwin.ui src/qtgui/ui/networkeditdlg.ui src/qtgui/ui/nickeditdlg.ui diff --git a/src/client/buffer.cpp b/src/client/buffer.cpp index 7afc15b5..7f4d885a 100644 --- a/src/client/buffer.cpp +++ b/src/client/buffer.cpp @@ -43,7 +43,6 @@ Buffer::Buffer(BufferId bufid) { } Buffer::~Buffer() { - //qDebug() << "destroying buffer"; //delete widget; /* QSettings s; diff --git a/src/client/buffertreemodel.cpp b/src/client/buffertreemodel.cpp index 3f0a2adb..37fe63bf 100644 --- a/src/client/buffertreemodel.cpp +++ b/src/client/buffertreemodel.cpp @@ -145,13 +145,13 @@ QModelIndex BufferTreeModel::getOrCreateNetworkItemIndex(Buffer *buffer) { QModelIndex BufferTreeModel::getOrCreateBufferItemIndex(Buffer *buffer) { QModelIndex networkItemIndex = getOrCreateNetworkItemIndex(buffer); - + if(bufferItem.contains(buffer)) { return index(bufferItem[buffer]->row(), 0, networkItemIndex); } else { // first we determine the parent of the new Item TreeItem *networkItem = static_cast(networkItemIndex.internalPointer()); - + Q_ASSERT(networkItem); int nextRow = networkItem->childCount(); beginInsertRows(networkItemIndex, nextRow, nextRow); @@ -257,3 +257,11 @@ void BufferTreeModel::selectBuffer(Buffer *buffer) { QModelIndex index = getOrCreateBufferItemIndex(buffer); emit selectionChanged(index); } + +// EgS: check if this makes sense! +void BufferTreeModel::clear() { + TreeModel::clear(); + networkItem.clear(); + bufferItem.clear(); +} + diff --git a/src/client/buffertreemodel.h b/src/client/buffertreemodel.h index 23471ad8..91fe43d5 100644 --- a/src/client/buffertreemodel.h +++ b/src/client/buffertreemodel.h @@ -67,6 +67,7 @@ public: virtual Qt::ItemFlags flags(const QModelIndex &index) const; // void clearActivity(Buffer *buffer); + void clear(); // EgS: check this public slots: void bufferUpdated(Buffer *); diff --git a/src/client/client.cpp b/src/client/client.cpp index 938d1072..85096c7b 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -114,9 +114,9 @@ void Client::init() { Client::~Client() { //delete mainUi; //delete _bufferModel; - foreach(Buffer *buf, buffers.values()) delete buf; + foreach(Buffer *buf, buffers.values()) delete buf; // this is done by disconnectFromCore()! ClientProxy::destroy(); - + Q_ASSERT(!buffers.count()); } BufferTreeModel *Client::bufferModel() { @@ -150,14 +150,6 @@ void Client::disconnectFromCore() { disconnectFromLocalCore(); coreSocketDisconnected(); } - /* Clear internal data. Hopefully nothing relies on it at this point. */ - coreConnectionInfo.clear(); - sessionData.clear(); - //foreach(Buffer *buf, buffers.values()) delete buf; - qDebug() << "barfoo"; - _bufferModel->clear(); - //qDeleteAll(buffers); - qDebug() << "foobar"; } void Client::coreSocketConnected() { @@ -173,6 +165,21 @@ void Client::coreSocketConnected() { void Client::coreSocketDisconnected() { connectedToCore = false; emit disconnected(); + /* Clear internal data. Hopefully nothing relies on it at this point. */ + _bufferModel->clear(); + // Buffers, if deleted, send a signal that causes their removal from buffers and bufferIds. + // So we cannot simply go through the array in a loop (or use qDeleteAll) for deletion... + while(buffers.count()) { delete buffers.take(buffers.keys()[0]); } + Q_ASSERT(!buffers.count()); // should be empty now! + Q_ASSERT(!bufferIds.count()); + coreConnectionInfo.clear(); + sessionData.clear(); + nicks.clear(); + netConnected.clear(); + netsAwaitingInit.clear(); + ownNick.clear(); + layoutQueue.clear(); + layoutTimer->stop(); } void Client::recvCoreState(const QVariant &state) { @@ -308,6 +315,7 @@ Buffer * Client::buffer(BufferId id) { connect(b, SIGNAL(userInput(BufferId, QString)), client, SLOT(userInput(BufferId, QString))); connect(b, SIGNAL(bufferUpdated(Buffer *)), client, SIGNAL(bufferUpdated(Buffer *))); connect(b, SIGNAL(bufferDestroyed(Buffer *)), client, SIGNAL(bufferDestroyed(Buffer *))); + connect(b, SIGNAL(bufferDestroyed(Buffer *)), client, SLOT(removeBuffer(Buffer *))); buffers[id] = b; emit client->bufferUpdated(b); } @@ -318,6 +326,11 @@ QList Client::allBufferIds() { return buffers.keys(); } +void Client::removeBuffer(Buffer *b) { + buffers.remove(b->bufferId()); + bufferIds.remove(b->bufferId().uid()); +} + void Client::recvNetworkState(QString net, QVariant state) { netsAwaitingInit.removeAll(net); netConnected[net] = true; diff --git a/src/client/client.h b/src/client/client.h index a974978c..a55a92b2 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -116,6 +116,8 @@ class Client : public QObject { void recvBacklogData(BufferId, const QList &, bool); void updateBufferId(BufferId); + void removeBuffer(Buffer *); + void layoutMsg(); private: diff --git a/src/client/treemodel.h b/src/client/treemodel.h index 2b7928c5..d73b8fcc 100644 --- a/src/client/treemodel.h +++ b/src/client/treemodel.h @@ -71,7 +71,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; - void clear(); + virtual void clear(); protected: bool removeRow(int row, const QModelIndex &parent = QModelIndex()); diff --git a/src/qtgui/CMakeLists.txt b/src/qtgui/CMakeLists.txt index d50af804..dd5a73c2 100644 --- a/src/qtgui/CMakeLists.txt +++ b/src/qtgui/CMakeLists.txt @@ -4,7 +4,7 @@ SET(qtgui_HDRS style.h) SET(qtgui_MOCS bufferview.h bufferviewfilter.h bufferwidget.h channelwidgetinput.h chatline.h chatwidget.h coreconnectdlg.h guisettings.h identities.h mainwin.h qtgui.h serverlist.h settingsdlg.h settingspages.h tabcompleter.h) SET(qtgui_UICS identitiesdlg.ui identitieseditdlg.ui networkeditdlg.ui mainwin.ui - nickeditdlg.ui serverlistdlg.ui servereditdlg.ui coreconnectdlg.ui ircwidget.ui + nickeditdlg.ui serverlistdlg.ui servereditdlg.ui coreconnectdlg.ui bufferviewwidget.ui bufferwidget.ui settingsdlg.ui buffermgmntsettingspage.ui connectionsettingspage.ui) diff --git a/src/qtgui/mainwin.cpp b/src/qtgui/mainwin.cpp index 5b196143..0824c811 100644 --- a/src/qtgui/mainwin.cpp +++ b/src/qtgui/mainwin.cpp @@ -149,6 +149,7 @@ void MainWin::connectedToCore() { ui.menuViews->setEnabled(true); ui.menuCore->setEnabled(true); + ui.actionConnectCore->setEnabled(false); ui.actionDisconnectCore->setEnabled(true); ui.actionNetworkList->setEnabled(true); ui.bufferWidget->show(); diff --git a/src/qtgui/ui/ircwidget.ui b/src/qtgui/ui/ircwidget.ui deleted file mode 100644 index 5ddc795a..00000000 --- a/src/qtgui/ui/ircwidget.ui +++ /dev/null @@ -1,44 +0,0 @@ - - IrcWidget - - - - 0 - 0 - 733 - 531 - - - - Form - - - - 9 - - - 6 - - - - - QTabWidget::South - - - QTabWidget::Rounded - - - 0 - - - - No connection - - - - - - - - -