From: Marcus Eggenberger Date: Sun, 4 May 2008 14:36:41 +0000 (+0000) Subject: fixing crashes when removing buffers from a view X-Git-Tag: 0.2.0-beta1~7 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=29b3fd2d4ee33d8bc72ef28982e5a6e963892991;hp=d54beb43e2714e0c035271bc3f32fc869551c6cb fixing crashes when removing buffers from a view --- diff --git a/src/uisupport/bufferview.cpp b/src/uisupport/bufferview.cpp index c168eaaa..180db0da 100644 --- a/src/uisupport/bufferview.cpp +++ b/src/uisupport/bufferview.cpp @@ -191,10 +191,10 @@ void BufferView::joinChannel(const QModelIndex &index) { } void BufferView::keyPressEvent(QKeyEvent *event) { - if(event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) { + if((event->key() == Qt::Key_Backspace || event->key() == Qt::Key_Delete) && !selectionModel()->selectedIndexes().isEmpty()) { event->accept(); QModelIndex index = selectionModel()->selectedIndexes().first(); - if(index.isValid()) { + if(index.isValid() && index.data(NetworkModel::ItemTypeRole) == NetworkModel::BufferItemType) { emit removeBuffer(index); } } diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index ec6a56e4..59dd184f 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -18,10 +18,10 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include - #include "bufferviewfilter.h" +#include + #include "buffermodel.h" #include "client.h" #include "networkmodel.h" @@ -155,9 +155,9 @@ void BufferViewFilter::addBuffer(const BufferId &bufferId) { } void BufferViewFilter::removeBuffer(const QModelIndex &index) { - if(!config()) + if(!config() || !index.isValid() || index.data(NetworkModel::ItemTypeRole) != NetworkModel::BufferItemType) return; - + BufferId bufferId = data(index, NetworkModel::BufferIdRole).value(); config()->requestRemoveBuffer(bufferId); } @@ -282,7 +282,7 @@ void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start, void BufferViewFilter::checkPreviousCurrentForRemoval(const QModelIndex ¤t, const QModelIndex &previous) { Q_UNUSED(current); if(previous.isValid()) - QCoreApplication::instance()->postEvent(this, new CheckRemovalEvent(previous)); + QCoreApplication::postEvent(this, new CheckRemovalEvent(previous)); } void BufferViewFilter::customEvent(QEvent *event) { diff --git a/version.inc b/version.inc index 44ca5afa..f6692a5c 100644 --- a/version.inc +++ b/version.inc @@ -4,8 +4,8 @@ { using namespace Global; quasselVersion = "0.2.0-beta1-pre"; - quasselDate = "2008-05-03"; - quasselBuild = 810; + quasselDate = "2008-05-04"; + quasselBuild = 814; //! Minimum client build number the core needs clientBuildNeeded = 731;