Skip to content

Commit

Permalink
Fix a crash
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Sep 11, 2015
1 parent 526073f commit 6d74bbd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,37 @@
#include "Process/ScenarioModel.hpp"
void DisplayedElementsModel::setSelection(const Selection & s)
{
m_startEvent->selection.set(s.find(m_startEvent) != s.end());
m_endEvent->selection.set(s.find(m_endEvent) != s.end());
bool startev{}, endev{}, starttn{}, endtn{}, startst{}, endst{}, cst{};
for(const auto& elt : s)
{
ISCORE_ASSERT(elt);

if(elt == m_startEvent)
startev = true;
else if(elt == m_endEvent)
endev = true;
else if(elt == m_startNode)
starttn = true;
else if(elt == m_endNode)
endtn = true;
else if(elt == m_startState)
startst = true;
else if(elt == m_endState)
endst = true;
else if(elt == m_constraint)
cst = true;
}

if(m_startEvent) m_startEvent->selection.set(startev);
if(m_endEvent) m_endEvent->selection.set(endev);

m_startState->selection.set(s.find(m_startState) != s.end());
m_endState->selection.set(s.find(m_endState) != s.end());
if(m_startState) m_startState->selection.set(starttn);
if(m_endState) m_endState->selection.set(endtn);

m_startNode->selection.set(s.find(m_startNode) != s.end());
m_endNode->selection.set(s.find(m_endNode) != s.end());
if(m_startNode) m_startState->selection.set(startst);
if(m_endNode) m_endState->selection.set(endst);

m_constraint->selection.set(s.find(m_constraint) != s.end());
if(m_constraint) m_endState->selection.set(cst);
}

void DisplayedElementsModel::setDisplayedConstraint(const ConstraintModel *constraint)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <QObject>
#include <QPointer>
#include <iscore/selection/Selection.hpp>

class ConstraintModel;
Expand All @@ -25,14 +26,14 @@ class DisplayedElementsModel
const StateModel& endState() const;

private:
const TimeNodeModel* m_startNode{};
const TimeNodeModel* m_endNode{};
QPointer<const TimeNodeModel> m_startNode{};
QPointer<const TimeNodeModel> m_endNode{};

const EventModel* m_startEvent{};
const EventModel* m_endEvent{};
QPointer<const EventModel> m_startEvent{};
QPointer<const EventModel> m_endEvent{};

const StateModel* m_startState{};
const StateModel* m_endState{};
QPointer<const StateModel> m_startState{};
QPointer<const StateModel> m_endState{};

const ConstraintModel* m_constraint{};
QPointer<const ConstraintModel> m_constraint{};
};

0 comments on commit 6d74bbd

Please sign in to comment.