| 633 | } |
| 634 | |
| 635 | void |
| 636 | ReadNodePrivate::createReadNode(bool throwErrors, |
| 637 | const std::string& filename, |
| 638 | const boost::shared_ptr<NodeSerialization>& serialization) |
| 639 | { |
| 640 | if (creatingReadNode) { |
| 641 | return; |
| 642 | } |
| 643 | |
| 644 | SetCreatingReaderRAIIFlag creatingNode__(this); |
| 645 | QString qpattern = QString::fromUtf8( filename.c_str() ); |
| 646 | std::string ext = QtCompat::removeFileExtension(qpattern).toLower().toStdString(); |
| 647 | std::string readerPluginID; |
| 648 | boost::shared_ptr<KnobString> pluginIDKnob = pluginIDStringKnob.lock(); |
| 649 | readerPluginID = pluginIDKnob->getValue(); |
| 650 | |
| 651 | |
| 652 | if ( readerPluginID.empty() ) { |
| 653 | boost::shared_ptr<KnobChoice> pluginChoiceKnob = pluginSelectorKnob.lock(); |
| 654 | int pluginChoice_i = pluginChoiceKnob->getValue(); |
| 655 | if (pluginChoice_i == 0) { |
| 656 | //Use default |
| 657 | readerPluginID = appPTR->getReaderPluginIDForFileType(ext); |
| 658 | } else { |
| 659 | std::vector<ChoiceOption> entries = pluginChoiceKnob->getEntries_mt_safe(); |
| 660 | if ( (pluginChoice_i >= 0) && ( pluginChoice_i < (int)entries.size() ) ) { |
| 661 | readerPluginID = entries[pluginChoice_i].id; |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | // If the plug-in is the same, do not create a new decoder. |
| 667 | if (embeddedPlugin && embeddedPlugin->getPluginID() == readerPluginID) { |
| 668 | boost::shared_ptr<KnobFile> fileKnob = inputFileKnob.lock(); |
| 669 | assert(fileKnob); |
| 670 | if (fileKnob) { |
| 671 | // Make sure instance changed action is called on the decoder and not caught in our knobChanged handler. |
| 672 | embeddedPlugin->getEffectInstance()->onKnobValueChanged_public(fileKnob.get(), eValueChangedReasonNatronInternalEdited, _publicInterface->getCurrentTime(), ViewSpec(0), true); |
| 673 | |
| 674 | } |
| 675 | |
| 676 | return; |
| 677 | } |
| 678 | //Destroy any previous reader |
| 679 | //This will store the serialization of the generic knobs |
| 680 | destroyReadNode(); |
| 681 | |
| 682 | bool defaultFallback = false; |
| 683 | |
| 684 | if (readerPluginID.empty()) { |
| 685 | if (throwErrors) { |
| 686 | QString message = tr("Could not find a decoder to read %1 file format") |
| 687 | .arg( QString::fromUtf8( ext.c_str() ) ); |
| 688 | throw std::runtime_error( message.toStdString() ); |
| 689 | } |
| 690 | defaultFallback = true; |
| 691 | |
| 692 | } |
no test coverage detected