Commit f2cbe272 authored by Jan Möbius's avatar Jan Möbius

Use objectids in move plugin instead of pointers (Fixes crash when tab is...

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
parent 722edfbf
......@@ -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()));
......
......@@ -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<movePropsWidget*>::iterator it = propsWindows_.begin();
it != propsWindows_.end(); it++) {
if ((*it)->getBaseObjectData() == _obj)
if ( (*it)->getBaseObjectDataId() == _obj->id() )
return *it;
}
return 0;
......
......@@ -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<movePropsWidget*> 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_;
......
......@@ -43,8 +43,8 @@
#include "MoveProps.hh"
#include <QtGui>
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
......@@ -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_;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment