Commit dee93d1de44f481eb3bc9376a505bece3a1a3a0a

Authored by Charles Otto
1 parent 5735462e

Fix an issue preventing stream from working correctly when called via project

Basically, description() now relies on firstAvailablePropertyIndex being
set correctly, and this is done in Object::init(file). If an object is
not created via the plugin system, Object::init(file) is never called.

Also, description is now called as part of smartCopy, which is of course
called when project() const is called on a timeVarying transform.
Showing 1 changed file with 15 additions and 15 deletions
openbr/plugins/stream.cpp
@@ -1535,21 +1535,21 @@ public: @@ -1535,21 +1535,21 @@ public:
1535 1535
1536 void project(const Template &src, Template &dst) const 1536 void project(const Template &src, Template &dst) const
1537 { 1537 {
1538 - basis.project(src,dst); 1538 + basis->project(src,dst);
1539 } 1539 }
1540 1540
1541 void projectUpdate(const Template &src, Template &dst) 1541 void projectUpdate(const Template &src, Template &dst)
1542 { 1542 {
1543 - basis.projectUpdate(src,dst); 1543 + basis->projectUpdate(src,dst);
1544 } 1544 }
1545 void projectUpdate(const TemplateList &src, TemplateList &dst) 1545 void projectUpdate(const TemplateList &src, TemplateList &dst)
1546 { 1546 {
1547 - basis.projectUpdate(src,dst); 1547 + basis->projectUpdate(src,dst);
1548 } 1548 }
1549 1549
1550 void train(const QList<TemplateList> &data) 1550 void train(const QList<TemplateList> &data)
1551 { 1551 {
1552 - basis.train(data); 1552 + basis->train(data);
1553 } 1553 }
1554 1554
1555 virtual void finalize(TemplateList &output) 1555 virtual void finalize(TemplateList &output)
@@ -1567,10 +1567,10 @@ public: @@ -1567,10 +1567,10 @@ public:
1567 1567
1568 trainable = transform->trainable; 1568 trainable = transform->trainable;
1569 1569
1570 - basis.setParent(this->parent());  
1571 - basis.transforms.clear();  
1572 - basis.activeFrames = this->activeFrames;  
1573 - basis.readMode = this->readMode; 1570 + basis = QSharedPointer<DirectStreamTransform>((DirectStreamTransform *) Transform::make("DirectStream",this));
  1571 + basis->transforms.clear();
  1572 + basis->activeFrames = this->activeFrames;
  1573 + basis->readMode = this->readMode;
1574 1574
1575 // We need at least a CompositeTransform * to acess transform's children. 1575 // We need at least a CompositeTransform * to acess transform's children.
1576 CompositeTransform *downcast = dynamic_cast<CompositeTransform *> (transform); 1576 CompositeTransform *downcast = dynamic_cast<CompositeTransform *> (transform);
@@ -1579,14 +1579,14 @@ public: @@ -1579,14 +1579,14 @@ public:
1579 // basis with 1 stage. 1579 // basis with 1 stage.
1580 if (!downcast || QString(transform->metaObject()->className()) != "br::PipeTransform") 1580 if (!downcast || QString(transform->metaObject()->className()) != "br::PipeTransform")
1581 { 1581 {
1582 - basis.transforms.append(transform);  
1583 - basis.init(); 1582 + basis->transforms.append(transform);
  1583 + basis->init();
1584 return; 1584 return;
1585 } 1585 }
1586 if (downcast->transforms.empty()) 1586 if (downcast->transforms.empty())
1587 { 1587 {
1588 qWarning("Trying to set up empty stream"); 1588 qWarning("Trying to set up empty stream");
1589 - basis.init(); 1589 + basis->init();
1590 return; 1590 return;
1591 } 1591 }
1592 1592
@@ -1634,21 +1634,21 @@ public: @@ -1634,21 +1634,21 @@ public:
1634 } 1634 }
1635 } 1635 }
1636 1636
1637 - basis.transforms = transform_set;  
1638 - basis.init(); 1637 + basis->transforms = transform_set;
  1638 + basis->init();
1639 } 1639 }
1640 1640
1641 Transform *smartCopy(bool &newTransform) 1641 Transform *smartCopy(bool &newTransform)
1642 { 1642 {
1643 // We just want the DirectStream to begin with, so just return a copy of that. 1643 // We just want the DirectStream to begin with, so just return a copy of that.
1644 - DirectStreamTransform *res = (DirectStreamTransform *) basis.smartCopy(newTransform); 1644 + DirectStreamTransform *res = (DirectStreamTransform *) basis->smartCopy(newTransform);
1645 res->activeFrames = this->activeFrames; 1645 res->activeFrames = this->activeFrames;
1646 return res; 1646 return res;
1647 } 1647 }
1648 1648
1649 1649
1650 private: 1650 private:
1651 - DirectStreamTransform basis; 1651 + QSharedPointer<DirectStreamTransform> basis;
1652 }; 1652 };
1653 1653
1654 BR_REGISTER(Transform, StreamTransform) 1654 BR_REGISTER(Transform, StreamTransform)