fixing crashes when removing buffers from a view
authorMarcus Eggenberger <egs@quassel-irc.org>
Sun, 4 May 2008 14:36:41 +0000 (14:36 +0000)
committerMarcus Eggenberger <egs@quassel-irc.org>
Sun, 4 May 2008 14:36:41 +0000 (14:36 +0000)
src/uisupport/bufferview.cpp
src/uisupport/bufferviewfilter.cpp
version.inc

index c168eaa..180db0d 100644 (file)
@@ -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);
     }
   }
index ec6a56e..59dd184 100644 (file)
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
-#include <QCoreApplication>
-
 #include "bufferviewfilter.h"
 
+#include <QCoreApplication>
+
 #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<BufferId>();
   config()->requestRemoveBuffer(bufferId);
 }
@@ -282,7 +282,7 @@ void BufferViewFilter::source_rowsInserted(const QModelIndex &parent, int start,
 void BufferViewFilter::checkPreviousCurrentForRemoval(const QModelIndex &current, 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) {
index 44ca5af..f6692a5 100644 (file)
@@ -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;