Commit 18a33a56d23c21640c99c81e47e11c38f77cdabc

Authored by Scott Klum
1 parent 775579ba

Switched back to readMode, improved solution

openbr/openbr_plugin.cpp
... ... @@ -703,7 +703,14 @@ void Object::setProperty(const QString &name, QVariant value)
703 703 int index = metaObject()->indexOfProperty(qPrintable(name));
704 704 if (index != -1) type = metaObject()->property(index).typeName();
705 705  
706   - if ((type.startsWith("QList<") && type.endsWith(">")) || (type == "QStringList")) {
  706 + if (metaObject()->property(index).isEnumType()) {
  707 + // This is necessary because setProperty can only set enums
  708 + // using its integer value if the QVariant is of type int (or uint)
  709 + bool ok;
  710 + int v = value.toInt(&ok);
  711 + if (ok)
  712 + value = v;
  713 + } else if ((type.startsWith("QList<") && type.endsWith(">")) || (type == "QStringList")) {
707 714 QVariantList elements;
708 715 if (value.canConvert<QVariantList>()) {
709 716 elements = value.value<QVariantList>();
... ... @@ -761,13 +768,6 @@ void Object::setProperty(const QString &amp;name, QVariant value)
761 768 if (value.isNull()) value = true;
762 769 else if (value == "false") value = false;
763 770 else if (value == "true") value = true;
764   - } else if (type.startsWith("br::") /* Pray to science it's safe to assume these are enums */) {
765   - bool ok;
766   - int enumIndex = value.toInt(&ok);
767   - if (ok) {
768   - QMetaEnum metaEnum = metaObject()->enumerator(metaObject()->indexOfEnumerator(type.toStdString().c_str()));
769   - value = metaEnum.value(enumIndex);
770   - }
771 771 }
772 772  
773 773 if (!QObject::setProperty(qPrintable(name), value) && !type.isEmpty())
... ...
openbr/plugins/stream.cpp
... ... @@ -1058,7 +1058,7 @@ public:
1058 1058 if (src.empty())
1059 1059 return;
1060 1060  
1061   - bool res = readStage->dataSource.open(src,br::Idiocy::DistributeFrames);
  1061 + bool res = readStage->dataSource.open(src,readMode);
1062 1062 if (!res) {
1063 1063 qDebug("stream failed to open %s", qPrintable(dst[0].file.name));
1064 1064 return;
... ...