| 1140 | } |
| 1141 | |
| 1142 | void |
| 1143 | ReadNode::onEffectCreated(bool mayCreateFileDialog, |
| 1144 | const CreateNodeArgs& args) |
| 1145 | { |
| 1146 | //If we already loaded the Reader, do not do anything |
| 1147 | NodePtr p = getEmbeddedReader(); |
| 1148 | if (p) { |
| 1149 | // Ensure the plug-in ID knob has the same value as the created reader: |
| 1150 | // The reader might have been created in onKnobsAboutToBeLoaded() however the knobs |
| 1151 | // get loaded afterwards and the plug-in ID could not reflect the underlying plugin |
| 1152 | KnobStringPtr pluginIDKnob = _imp->pluginIDStringKnob.lock(); |
| 1153 | if (pluginIDKnob) { |
| 1154 | pluginIDKnob->setValue(p->getPluginID()); |
| 1155 | } |
| 1156 | return; |
| 1157 | } |
| 1158 | |
| 1159 | _imp->wasCreatedAsHiddenNode = args.getProperty<bool>(kCreateNodeArgsPropNoNodeGUI); |
| 1160 | |
| 1161 | bool throwErrors = false; |
| 1162 | std::string pattern; |
| 1163 | |
| 1164 | if (mayCreateFileDialog) { |
| 1165 | if ( !getApp()->isBackground() ) { |
| 1166 | pattern = getApp()->openImageFileDialog(); |
| 1167 | |
| 1168 | // File dialog was closed, ignore |
| 1169 | if ( pattern.empty() ) { |
| 1170 | throw std::runtime_error(""); |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | //The user selected a file, if it fails to read do not create the node |
| 1175 | throwErrors = true; |
| 1176 | } else { |
| 1177 | std::vector<std::string> defaultParamValues = args.getPropertyN<std::string>(kCreateNodeArgsPropNodeInitialParamValues); |
| 1178 | std::vector<std::string>::iterator foundFileName = std::find(defaultParamValues.begin(), defaultParamValues.end(), std::string(kOfxImageEffectFileParamName)); |
| 1179 | if (foundFileName != defaultParamValues.end()) { |
| 1180 | std::string propName(kCreateNodeArgsPropParamValue); |
| 1181 | propName += "_"; |
| 1182 | propName += kOfxImageEffectFileParamName; |
| 1183 | pattern = args.getProperty<std::string>(propName); |
| 1184 | } |
| 1185 | } |
| 1186 | _imp->createReadNode( throwErrors, pattern, NodeSerializationPtr() ); |
| 1187 | _imp->refreshPluginSelectorKnob(); |
| 1188 | } |
| 1189 | |
| 1190 | void |
| 1191 | ReadNode::onKnobsAboutToBeLoaded(const NodeSerializationPtr& serialization) |
no test coverage detected