mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-20 02:07:23 +01:00
see #1976 disable "Paste" context menu items when object in the clipboard has been deleted
This commit is contained in:
parent
609ba61066
commit
7d3b11796d
@ -1,10 +1,21 @@
|
||||
2011-01-22 vadim <vadim@netcitadel.com>
|
||||
|
||||
* FWObjectDatabase_create_object.cpp (registerObjectType): see
|
||||
#1972 implemented mechanism that allows me to register new object
|
||||
types created and used outside of libfwbuilder API. This means
|
||||
FWObjectDatabase can then copy and manipulate object trees that
|
||||
use these new object types.
|
||||
* GroupObjectDialog.cpp (setupPopupMenu): see #1976 "Crash when
|
||||
deleting firewall object from rule after export / import library"
|
||||
Crash occurred as the result of the following sequence of actions
|
||||
in the GUI: 1) use context menu item "Cut" to delete an object in
|
||||
the tree, 2) open object group or rule and use context menu item
|
||||
"Paste" to add it, 3) export library to an external file, 4)
|
||||
import this library into different data file, 5) save the data
|
||||
file. Saved data file is invalid XML since it has unsatisfied
|
||||
reference and some operations on it cause crash. The problem is
|
||||
that since it is a reference to the object that is being added in
|
||||
case of both groups and rules, we end up with a group or rule with
|
||||
a reference to an object that is located in Deleted Objects
|
||||
library. Deleted Objects library is not included when a library
|
||||
file is merged into data file and this leads to a dangling
|
||||
reference. The fix is to not allow Paste if object in the
|
||||
clipboard has been deleted.
|
||||
|
||||
* NamedObjectsAndGroupsSupport.cpp (saveObjectGroups): see #1968,
|
||||
#1972 Class NamedObjectsManager maintains its own copy of object
|
||||
|
||||
@ -691,7 +691,7 @@ void GroupObjectDialog::listContextMenu(const QPoint & pos)
|
||||
|
||||
void GroupObjectDialog::setupPopupMenu(const QPoint &pos)
|
||||
{
|
||||
QMenu *popup=new QMenu(this);
|
||||
QMenu *popup = new QMenu(this);
|
||||
|
||||
if (selectedObject!=NULL)
|
||||
{
|
||||
@ -701,18 +701,26 @@ void GroupObjectDialog::setupPopupMenu(const QPoint &pos)
|
||||
popup->addAction(tr("Edit"), this, SLOT(openObject()));
|
||||
}
|
||||
|
||||
QAction *copyID =popup->addAction(tr("Copy"), this, SLOT(copyObj()));
|
||||
QAction *cutID =popup->addAction(tr("Cut"), this, SLOT(cutObj()));
|
||||
QAction *pasteID=popup->addAction(tr("Paste"), this, SLOT(pasteObj()));
|
||||
QAction *delID =popup->addAction(tr("Delete"),this, SLOT(deleteObj()));
|
||||
QAction *copyID = popup->addAction(tr("Copy"), this, SLOT(copyObj()));
|
||||
QAction *cutID = popup->addAction(tr("Cut"), this, SLOT(cutObj()));
|
||||
QAction *pasteID = popup->addAction(tr("Paste"), this, SLOT(pasteObj()));
|
||||
QAction *delID = popup->addAction(tr("Delete"),this, SLOT(deleteObj()));
|
||||
|
||||
copyID->setEnabled(selectedObject!=NULL &&
|
||||
! FWBTree().isSystem(selectedObject) );
|
||||
cutID->setEnabled(selectedObject!=NULL &&
|
||||
! FWBTree().isSystem(obj) &&
|
||||
! obj->isReadOnly() );
|
||||
|
||||
// see #1976 do not allow pasting object that has been deleted
|
||||
FWObject *obj_in_clipboard = FWObjectClipboard::obj_clipboard->getObject();
|
||||
bool obj_deleted = (obj_in_clipboard &&
|
||||
obj_in_clipboard->getParent()->getId() ==
|
||||
FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||
|
||||
pasteID->setEnabled(! FWBTree().isSystem(obj) &&
|
||||
! obj->isReadOnly() );
|
||||
! obj->isReadOnly() && ! obj_deleted);
|
||||
|
||||
delID->setEnabled(selectedObject!=NULL &&
|
||||
! FWBTree().isSystem(obj) &&
|
||||
! obj->isReadOnly() );
|
||||
|
||||
@ -704,31 +704,48 @@ void RuleSetView::addColumnRelatedMenu(QMenu *menu, const QModelIndex &index,
|
||||
FWObject *object = getObject(pos, index);
|
||||
|
||||
QAction *editID = menu->addAction(
|
||||
tr("Edit") , this , SLOT( editSelected() ) );
|
||||
tr("Edit") , this , SLOT( editSelected() ) );
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
QAction *copyID = menu->addAction(
|
||||
tr("Copy") , this , SLOT( copySelectedObject() ) );
|
||||
tr("Copy") , this , SLOT( copySelectedObject() ) );
|
||||
|
||||
QAction *cutID = menu->addAction(
|
||||
tr("Cut") , this , SLOT( cutSelectedObject() ) );
|
||||
menu->addAction( tr("Paste") , this , SLOT( pasteObject() ) );
|
||||
tr("Cut") , this , SLOT( cutSelectedObject() ) );
|
||||
|
||||
QAction *pasteID = menu->addAction(
|
||||
tr("Paste") , this , SLOT( pasteObject() ) );
|
||||
|
||||
QAction *delID =menu->addAction(
|
||||
tr("Delete") , this , SLOT( deleteSelectedObject() ) );
|
||||
menu->addSeparator();
|
||||
QAction *fndID = menu->addAction(
|
||||
tr("Where used") , this , SLOT( findWhereUsedSlot()));
|
||||
QAction *revID = menu->addAction(
|
||||
tr("Reveal in tree") ,this , SLOT( revealObjectInTree() ) );
|
||||
menu->addSeparator();
|
||||
QAction *negID = menu->addAction(
|
||||
tr("Negate") , this , SLOT( negateRE() ) );
|
||||
tr("Delete") , this , SLOT( deleteSelectedObject() ) );
|
||||
|
||||
if (object == NULL || re->isAny())
|
||||
editID->setEnabled(false);
|
||||
menu->addSeparator();
|
||||
|
||||
QAction *fndID = menu->addAction(
|
||||
tr("Where used") , this , SLOT( findWhereUsedSlot()));
|
||||
|
||||
QAction *revID = menu->addAction(
|
||||
tr("Reveal in tree") ,this , SLOT( revealObjectInTree() ) );
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
QAction *negID = menu->addAction(
|
||||
tr("Negate") , this , SLOT( negateRE() ) );
|
||||
|
||||
if (object == NULL || re->isAny()) editID->setEnabled(false);
|
||||
copyID->setEnabled(!re->isAny());
|
||||
cutID->setEnabled(!re->isAny());
|
||||
delID->setEnabled(!re->isAny());
|
||||
|
||||
// see #1976 do not allow pasting object that has been deleted
|
||||
FWObject *obj_in_clipboard =
|
||||
FWObjectClipboard::obj_clipboard->getObject();
|
||||
bool obj_deleted = (obj_in_clipboard &&
|
||||
obj_in_clipboard->getParent()->getId() ==
|
||||
FWObjectDatabase::DELETED_OBJECTS_ID);
|
||||
pasteID->setEnabled(obj_in_clipboard!=NULL && !obj_deleted);
|
||||
|
||||
string cap_name;
|
||||
if (Policy::cast(md->getRuleSet())!=NULL) cap_name="negation_in_policy";
|
||||
if (NAT::cast(md->getRuleSet())!=NULL) cap_name="negation_in_nat";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user