Gui: [skip ci] add some security checks before dereferencing pointer to QTreeWidgetItem
This commit is contained in:
@@ -483,7 +483,7 @@ ParameterGroup::~ParameterGroup()
|
||||
void ParameterGroup::contextMenuEvent ( QContextMenuEvent* event )
|
||||
{
|
||||
QTreeWidgetItem* item = currentItem();
|
||||
if (item->isSelected())
|
||||
if (item && item->isSelected())
|
||||
{
|
||||
expandAct->setEnabled(item->childCount() > 0);
|
||||
// do not allow to import parameters from a non-empty parameter group
|
||||
@@ -513,7 +513,7 @@ void ParameterGroup::keyPressEvent (QKeyEvent* event)
|
||||
void ParameterGroup::onDeleteSelectedItem()
|
||||
{
|
||||
QTreeWidgetItem* sel = currentItem();
|
||||
if (sel->isSelected() && sel->parent())
|
||||
if (sel && sel->isSelected() && sel->parent())
|
||||
{
|
||||
if ( QMessageBox::question(this, tr("Remove group"), tr("Do you really want to remove this parameter group?"),
|
||||
QMessageBox::Yes, QMessageBox::No|QMessageBox::Default|QMessageBox::Escape) ==
|
||||
@@ -537,7 +537,7 @@ void ParameterGroup::onDeleteSelectedItem()
|
||||
void ParameterGroup::onToggleSelectedItem()
|
||||
{
|
||||
QTreeWidgetItem* sel = currentItem();
|
||||
if (sel->isSelected())
|
||||
if (sel && sel->isSelected())
|
||||
{
|
||||
if (sel->isExpanded())
|
||||
sel->setExpanded(false);
|
||||
@@ -555,7 +555,7 @@ void ParameterGroup::onCreateSubgroup()
|
||||
if (ok && Gui::validateInput(this, name))
|
||||
{
|
||||
QTreeWidgetItem* item = currentItem();
|
||||
if (item->isSelected())
|
||||
if (item && item->isSelected())
|
||||
{
|
||||
ParameterGroupItem* para = static_cast<ParameterGroupItem*>(item);
|
||||
Base::Reference<ParameterGrp> hGrp = para->_hcGrp;
|
||||
@@ -581,7 +581,7 @@ void ParameterGroup::onExportToFile()
|
||||
if ( !file.isEmpty() )
|
||||
{
|
||||
QTreeWidgetItem* item = currentItem();
|
||||
if (item->isSelected())
|
||||
if (item && item->isSelected())
|
||||
{
|
||||
ParameterGroupItem* para = static_cast<ParameterGroupItem*>(item);
|
||||
Base::Reference<ParameterGrp> hGrp = para->_hcGrp;
|
||||
@@ -597,7 +597,7 @@ void ParameterGroup::onImportFromFile()
|
||||
if ( !file.isEmpty() )
|
||||
{
|
||||
QTreeWidgetItem* item = currentItem();
|
||||
if (item->isSelected())
|
||||
if (item && item->isSelected())
|
||||
{
|
||||
ParameterGroupItem* para = static_cast<ParameterGroupItem*>(item);
|
||||
Base::Reference<ParameterGrp> hGrp = para->_hcGrp;
|
||||
@@ -631,7 +631,7 @@ void ParameterGroup::onImportFromFile()
|
||||
void ParameterGroup::onRenameSelectedItem()
|
||||
{
|
||||
QTreeWidgetItem* sel = currentItem();
|
||||
if (sel->isSelected())
|
||||
if (sel && sel->isSelected())
|
||||
{
|
||||
editItem(sel, 0);
|
||||
}
|
||||
@@ -750,7 +750,7 @@ void ParameterValue::onChangeSelectedItem()
|
||||
void ParameterValue::onDeleteSelectedItem()
|
||||
{
|
||||
QTreeWidgetItem* sel = currentItem();
|
||||
if (sel->isSelected())
|
||||
if (sel && sel->isSelected())
|
||||
{
|
||||
takeTopLevelItem(indexOfTopLevelItem(sel));
|
||||
static_cast<ParameterValueItem*>(sel)->removeFromGroup();
|
||||
@@ -761,7 +761,7 @@ void ParameterValue::onDeleteSelectedItem()
|
||||
void ParameterValue::onRenameSelectedItem()
|
||||
{
|
||||
QTreeWidgetItem* sel = currentItem();
|
||||
if (sel->isSelected())
|
||||
if (sel && sel->isSelected())
|
||||
{
|
||||
editItem(sel, 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user