0000813: set colors dialog crash
This commit is contained in:
parent
43b7b9834d
commit
ba7be4f798
|
@ -187,6 +187,9 @@ bool Document::setEdit(Gui::ViewProvider* p, int ModNum)
|
|||
View3DInventor *activeView = dynamic_cast<View3DInventor *>(getActiveView());
|
||||
if (activeView && activeView->getViewer()->setEditingViewProvider(p,ModNum)) {
|
||||
d->_pcInEdit = p;
|
||||
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
|
||||
if (dlg)
|
||||
dlg->setDocumentName(this->getDocument()->getName());
|
||||
if (d->_pcInEdit->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId()))
|
||||
signalInEdit(*(static_cast<ViewProviderDocumentObject*>(d->_pcInEdit)));
|
||||
}
|
||||
|
|
|
@ -69,6 +69,8 @@ public:
|
|||
|
||||
const std::string& getDocumentName() const
|
||||
{ return documentName; }
|
||||
void setDocumentName(const std::string& doc)
|
||||
{ documentName = doc; }
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
virtual bool isAllowedAlterView(void) const
|
||||
|
@ -94,6 +96,8 @@ protected:
|
|||
/// List of TaskBoxes of that dialog
|
||||
std::vector<QWidget*> Content;
|
||||
ButtonPosition pos;
|
||||
|
||||
private:
|
||||
std::string documentName;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,11 +30,15 @@
|
|||
# include <QSet>
|
||||
#endif
|
||||
|
||||
#include <boost/signals.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "ui_TaskFaceColors.h"
|
||||
#include "TaskFaceColors.h"
|
||||
#include "ViewProviderExt.h"
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
|
@ -69,15 +73,20 @@ namespace PartGui {
|
|||
class FaceColors::Private
|
||||
{
|
||||
public:
|
||||
typedef boost::signals::connection Connection;
|
||||
Ui_TaskFaceColors* ui;
|
||||
ViewProviderPartExt* vp;
|
||||
App::DocumentObject* obj;
|
||||
Gui::Document* doc;
|
||||
std::vector<App::Color> current,perface;
|
||||
QSet<int> index;
|
||||
Connection connectDelDoc;
|
||||
Connection connectDelObj;
|
||||
|
||||
Private(ViewProviderPartExt* vp) : ui(new Ui_TaskFaceColors()), vp(vp)
|
||||
{
|
||||
obj = vp->getObject();
|
||||
doc = Gui::Application::Instance->getDocument(obj->getDocument());
|
||||
|
||||
// build up map edge->face
|
||||
TopTools_IndexedMapOfShape mapOfShape;
|
||||
|
@ -110,14 +119,33 @@ FaceColors::FaceColors(ViewProviderPartExt* vp, QWidget* parent)
|
|||
|
||||
FaceSelection* gate = new FaceSelection(d->vp->getObject());
|
||||
Gui::Selection().addSelectionGate(gate);
|
||||
|
||||
d->connectDelDoc = Gui::Application::Instance->signalDeleteDocument.connect(boost::bind
|
||||
(&FaceColors::slotDeleteDocument, this, _1));
|
||||
d->connectDelObj = Gui::Application::Instance->signalDeletedObject.connect(boost::bind
|
||||
(&FaceColors::slotDeleteObject, this, _1));
|
||||
}
|
||||
|
||||
FaceColors::~FaceColors()
|
||||
{
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
d->connectDelDoc.disconnect();
|
||||
d->connectDelObj.disconnect();
|
||||
delete d;
|
||||
}
|
||||
|
||||
void FaceColors::slotDeleteDocument(const Gui::Document& Doc)
|
||||
{
|
||||
if (d->doc == &Doc)
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
|
||||
void FaceColors::slotDeleteObject(const Gui::ViewProvider& obj)
|
||||
{
|
||||
if (d->vp == &obj)
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
|
||||
void FaceColors::on_defaultButton_clicked()
|
||||
{
|
||||
std::fill(d->perface.begin(), d->perface.end(), d->vp->ShapeColor.getValue());
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
namespace Gui {
|
||||
class Document;
|
||||
class ViewProvider;
|
||||
}
|
||||
|
||||
namespace PartGui {
|
||||
|
||||
class ViewProviderPartExt;
|
||||
|
@ -49,6 +54,8 @@ private Q_SLOTS:
|
|||
protected:
|
||||
void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
void changeEvent(QEvent *e);
|
||||
void slotDeleteDocument(const Gui::Document&);
|
||||
void slotDeleteObject(const Gui::ViewProvider&);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
|
|
|
@ -42,7 +42,6 @@ TaskDlgEditSketch::TaskDlgEditSketch(ViewProviderSketch *sketchView)
|
|||
: TaskDialog(),sketchView(sketchView)
|
||||
{
|
||||
assert(sketchView);
|
||||
documentName = sketchView->getObject()->getDocument()->getName();
|
||||
Constraints = new TaskSketcherConstrains(sketchView);
|
||||
General = new TaskSketcherGeneral(sketchView);
|
||||
Messages = new TaskSketcherMessages(sketchView);
|
||||
|
@ -77,7 +76,7 @@ bool TaskDlgEditSketch::accept()
|
|||
|
||||
bool TaskDlgEditSketch::reject()
|
||||
{
|
||||
std::string document = documentName; // needed because resetEdit() deletes this instance
|
||||
std::string document = getDocumentName(); // needed because resetEdit() deletes this instance
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.getDocument('%s').resetEdit()", document.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.getDocument('%s').recompute()", document.c_str());
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user