Skip to content

Commit

Permalink
fix execution bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Nov 18, 2015
1 parent 620ddf9 commit 2cd2027
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
OSSIADocumentPlugin::OSSIADocumentPlugin(iscore::Document& doc, QObject* parent):
iscore::DocumentDelegatePluginModel{doc, "OSSIADocumentPlugin", parent}
{
reload(doc.model());
//reload(doc.model());
}

void OSSIADocumentPlugin::reload(iscore::DocumentModel &doc)
Expand All @@ -29,6 +29,12 @@ void OSSIADocumentPlugin::reload(iscore::DocumentModel &doc)
m_base = new OSSIABaseScenarioElement{baseElement, this};
}

void OSSIADocumentPlugin::clear()
{
delete m_base;
m_base = nullptr;
}

OSSIABaseScenarioElement *OSSIADocumentPlugin::baseScenario() const
{
return m_base;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class OSSIADocumentPlugin final : public iscore::DocumentDelegatePluginModel
OSSIADocumentPlugin(iscore::Document& doc, QObject* parent);

void reload(iscore::DocumentModel& doc);
void clear();

OSSIABaseScenarioElement* baseScenario() const;

Expand Down
38 changes: 20 additions & 18 deletions base/plugins/iscore-plugin-ossia/OSSIAControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@ OSSIAConstraintElement &OSSIAControl::baseConstraint() const
return *currentDocument()->model().pluginModel<OSSIADocumentPlugin>()->baseScenario()->baseConstraint();
}

OSSIABaseScenarioElement&OSSIAControl::baseScenario() const
{
return *currentDocument()->model().pluginModel<OSSIADocumentPlugin>()->baseScenario();
}

void OSSIAControl::populateMenus(iscore::MenubarManager* menu)
{
}
Expand All @@ -122,27 +117,27 @@ void OSSIAControl::on_newDocument(iscore::Document* doc)

void OSSIAControl::on_loadedDocument(iscore::Document *doc)
{
if(auto plugmodel = doc->model().pluginModel<OSSIADocumentPlugin>())
{
plugmodel->reload(doc->model());
}
else
{
on_newDocument(doc);
}
on_newDocument(doc);
}

void OSSIAControl::on_play(bool b)
{
if(auto doc = currentDocument())
{
auto& cstr = *doc->model().pluginModel<OSSIADocumentPlugin>()->baseScenario()->baseConstraint();
if(b)
{
if(m_playing)
{
auto& cstr = *doc->model().pluginModel<OSSIADocumentPlugin>()->baseScenario()->baseConstraint();
cstr.OSSIAConstraint()->resume();
}
else
{
auto plugmodel = doc->model().pluginModel<OSSIADocumentPlugin>();
plugmodel->reload(doc->model());

auto& cstr = *plugmodel->baseScenario()->baseConstraint();

cstr.recreate();
cstr.play();

Expand All @@ -158,6 +153,7 @@ void OSSIAControl::on_play(bool b)
}
else
{
auto& cstr = *doc->model().pluginModel<OSSIADocumentPlugin>()->baseScenario()->baseConstraint();
cstr.OSSIAConstraint()->pause();
}
}
Expand All @@ -167,10 +163,16 @@ void OSSIAControl::on_stop()
{
if(auto doc = currentDocument())
{
auto& cstr = baseConstraint();
cstr.stop();
cstr.clear();
m_playing = false;

auto plugmodel = doc->model().pluginModel<OSSIADocumentPlugin>();
if(plugmodel && plugmodel->baseScenario())
{
auto& cstr = baseConstraint();
cstr.stop();
cstr.clear();
m_playing = false;
plugmodel->clear();
}

// If we can we resume listening
auto explorer = try_deviceExplorerFromObject(*doc);
Expand Down
1 change: 0 additions & 1 deletion base/plugins/iscore-plugin-ossia/OSSIAControl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class OSSIAControl final : public iscore::PluginControlInterface
void on_loadedDocument(iscore::Document* doc) override;

OSSIAConstraintElement& baseConstraint() const;
OSSIABaseScenarioElement& baseScenario() const;
std::shared_ptr<OSSIA::Device> localDevice() const
{ return m_localDevice; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void AddressBarItem::setTargetObject(ObjectPath && path)

void AddressBarItem::on_elementClicked(ClickableLabelItem * clicked)
{
int index = clicked->index();
std::size_t index = clicked->index();

if(index < m_currentPath.vec().size())
{
Expand Down

0 comments on commit 2cd2027

Please sign in to comment.