0000813: set colors dialog crash
This commit is contained in:
@@ -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());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user