Properly initialize _messageFilter in all cases, fixes #482
[quassel.git] / src / uisupport / networkmodelactionprovider.cpp
index 84a306c..149ef69 100644 (file)
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2005-08 by the Quassel Project                          *
+ *   Copyright (C) 2005-09 by the Quassel Project                          *
  *   devel@quassel-irc.org                                                 *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -169,9 +169,14 @@ void NetworkModelActionProvider::addActions(QMenu *menu, MessageFilter *filter,
   addActions(menu, QList<QModelIndex>() << Client::networkModel()->bufferIndex(msgBuffer), receiver, method);
 }
 
+void NetworkModelActionProvider::addActions(QMenu *menu, const QList<QModelIndex> &indexList, QObject *receiver,  const char *method, bool isCustomBufferView) {
+  addActions(menu, indexList, 0, receiver, method, isCustomBufferView);
+}
+
 // add a list of actions sensible for the current item(s)
 void NetworkModelActionProvider::addActions(QMenu *menu,
                                             const QList<QModelIndex> &indexList,
+                                            MessageFilter *filter,
                                             QObject *receiver,
                                             const char *method,
                                             bool isCustomBufferView)
@@ -180,6 +185,7 @@ void NetworkModelActionProvider::addActions(QMenu *menu,
     return;
 
   _indexList = indexList;
+  _messageFilter = filter;
   _receiver = receiver;
   _method = method;
 
@@ -504,10 +510,11 @@ void NetworkModelActionProvider::handleBufferAction(ActionType type, QAction *)
 void NetworkModelActionProvider::removeBuffers(const QModelIndexList &indexList) {
   QList<BufferInfo> inactive;
   foreach(QModelIndex index, indexList) {
-    if(!index.data(NetworkModel::ItemActiveRole).toBool()) {
-      BufferInfo info = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
-      if(info.isValid())
-        inactive << info;
+    BufferInfo info = index.data(NetworkModel::BufferInfoRole).value<BufferInfo>();
+    if(info.isValid()) {
+      if(info.type() == BufferInfo::QueryBuffer
+        || (info.type() == BufferInfo::ChannelBuffer && !index.data(NetworkModel::ItemActiveRole).toBool()))
+          inactive << info;
     }
   }
   QString msg;