From f2cbe272f3a9fe1ea1b89cb0976a67e1c9d5bfeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Tue, 22 Dec 2009 15:31:34 +0000 Subject: [PATCH] Use objectids in move plugin instead of pointers (Fixes crash when tab is visible but corresponding object has been deleted git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8029 383ad7c9-94d9-4d36-a494-682f7c89f535 --- MoveContextMenu.cc | 6 +++++- MovePlugin.cc | 35 +++++++++++++++++++++++------------ MovePlugin.hh | 10 ++++++++-- MoveProps.cc | 4 ++-- MoveProps.hh | 8 ++++---- 5 files changed, 42 insertions(+), 21 deletions(-) diff --git a/MoveContextMenu.cc b/MoveContextMenu.cc index 250214f..91a6e0b 100644 --- a/MoveContextMenu.cc +++ b/MoveContextMenu.cc @@ -47,6 +47,10 @@ //*********************************************************************************** +void MovePlugin::hideManipulator() { +// contextActionHide_ +} + void MovePlugin::showProps(){ QVariant contextObject = contextAction_->data(); @@ -72,7 +76,7 @@ void MovePlugin::showProps(){ if ( ! PluginFunctions::getObject(meshID,obj) ) return; - movePropsWidget* pW = new movePropsWidget(obj); + movePropsWidget* pW = new movePropsWidget(obj->id()); pW->setWindowTitle(QString((mNode->name()).c_str())); connect(pW->posButton,SIGNAL(clicked() ),this,SLOT(slotSetPosition())); diff --git a/MovePlugin.cc b/MovePlugin.cc index 639f667..b5b9499 100644 --- a/MovePlugin.cc +++ b/MovePlugin.cc @@ -145,14 +145,18 @@ void MovePlugin::pluginsInitialized() { contextAction_ = new QAction(tr("Set properties"), this); contextAction_->setToolTip(tr("Set properties")); contextAction_->setStatusTip( contextAction_->toolTip() ); + +// contextActionHide_ = new QAction(tr("Hide Manipulator"), this); +// contextActionHide_->setToolTip(tr("Hide Manipulator")); +// contextActionHide_->setStatusTip( contextActionHide_->toolTip() ); - emit addContextMenuItem(toAllTargets_ , CONTEXTNODEMENU ); - emit addContextMenuItem(contextAction_ , CONTEXTNODEMENU ); - - connect(toAllTargets_,SIGNAL(toggled(bool) ),this,SLOT(setAllTargets(bool))); + emit addContextMenuItem(toAllTargets_ , CONTEXTNODEMENU ); + emit addContextMenuItem(contextAction_ , CONTEXTNODEMENU ); +// emit addContextMenuItem(contextActionHide_ , CONTEXTNODEMENU ); - connect( contextAction_ , SIGNAL( triggered() ), - this, SLOT(showProps()) ); + connect( toAllTargets_ , SIGNAL(toggled(bool) ), this, SLOT(setAllTargets(bool))); + connect( contextAction_ , SIGNAL( triggered() ), this, SLOT(showProps()) ); +// connect( contextActionHide_ , SIGNAL( triggered() ), this, SLOT(hideManipulator()) ); //TOOLBAR toolbar_ = new QToolBar(tr("Transform and Move")); @@ -922,7 +926,9 @@ void MovePlugin::slotSetDirection() { // } // } - BaseObjectData* object = pW->getBaseObjectData(); + + BaseObjectData* object = 0; + PluginFunctions::getObject(pW->getBaseObjectDataId(),object); if ( object != 0 ) { if ( object->manipulatorNode()->visible() ){ @@ -987,7 +993,9 @@ void MovePlugin::slotTranslation() { // // } - BaseObjectData* object = pW->getBaseObjectData(); + BaseObjectData* object = 0; + PluginFunctions::getObject(pW->getBaseObjectDataId(),object); + if (object != 0) { if (object->manipulatorNode()->visible()) { @@ -1058,7 +1066,8 @@ void MovePlugin::slotMoveManipToCOG() { // } // } else { - BaseObjectData* object = pW->getBaseObjectData(); + BaseObjectData* object = 0; + PluginFunctions::getObject(pW->getBaseObjectDataId(),object); if ( object != 0 ) { if ( object->manipulatorNode()->visible() ){ @@ -1122,7 +1131,8 @@ void MovePlugin::slotRotate() { // } else { - BaseObjectData* object = pW->getBaseObjectData(); + BaseObjectData* object = 0; + PluginFunctions::getObject(pW->getBaseObjectDataId(),object); if (object != 0) { if (object->manipulatorNode()->visible() && (object->target() || !allTargets_)) { @@ -1192,7 +1202,8 @@ void MovePlugin::slotScale() { // } else { - BaseObjectData* object = pW->getBaseObjectData(); + BaseObjectData* object = 0; + PluginFunctions::getObject(pW->getBaseObjectDataId(),object); if (object != 0) { if (object->manipulatorNode()->visible() && (object->target() || !allTargets_)) { @@ -1418,7 +1429,7 @@ movePropsWidget* MovePlugin::getDialogWidget(BaseObjectData* _obj) { for(QList::iterator it = propsWindows_.begin(); it != propsWindows_.end(); it++) { - if ((*it)->getBaseObjectData() == _obj) + if ( (*it)->getBaseObjectDataId() == _obj->id() ) return *it; } return 0; diff --git a/MovePlugin.hh b/MovePlugin.hh index 9121dc6..cb62544 100644 --- a/MovePlugin.hh +++ b/MovePlugin.hh @@ -383,8 +383,11 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, private slots: - /// Show properties of move manipulator in a dialog + /// Show properties of move manipulator in a dialog ( Called via context for picking. Get the picked id from the Qvariant attached to the connected action) void showProps( ); + + /// Hide the manipulator( Called via context for picking. Get the picked id from the Qvariant attached to the connected action) + void hideManipulator(); /// Get properties dialog widget that is attached to BaseDataObject obj movePropsWidget* getDialogWidget(BaseObjectData* _obj); @@ -401,8 +404,11 @@ class MovePlugin : public QObject, BaseInterface, MouseInterface, KeyInterface, /// List of properties dialogs (each corresponding to one manipulator) QList propsWindows_; - /// Context menu entry + /// Context menu entry for showing per manipulator settings QAction* contextAction_; + + /// Context menu entry to hide a manipulator + QAction* contextActionHide_; /// Checked if transformation should be applied to all target objs QAction* toAllTargets_; diff --git a/MoveProps.cc b/MoveProps.cc index aa18ac7..9d43a09 100644 --- a/MoveProps.cc +++ b/MoveProps.cc @@ -43,8 +43,8 @@ #include "MoveProps.hh" #include -movePropsWidget::movePropsWidget(BaseObjectData* obj, QWidget *parent) - : QWidget(parent), obd(obj) +movePropsWidget::movePropsWidget(int obj, QWidget *parent) + : QWidget(parent), obj_(obj) { setupUi(this); } \ No newline at end of file diff --git a/MoveProps.hh b/MoveProps.hh index f9b4175..6e0feb9 100644 --- a/MoveProps.hh +++ b/MoveProps.hh @@ -50,13 +50,13 @@ class movePropsWidget : public QWidget, public Ui::setProps Q_OBJECT public: - movePropsWidget(BaseObjectData* obj, QWidget *parent = 0); + movePropsWidget(int obj, QWidget *parent = 0); - BaseObjectData* getBaseObjectData() { return obd; }; + int getBaseObjectDataId() { return obj_; }; private: - BaseObjectData* obd; - + int obj_; + }; -- GitLab