| 852 | } |
| 853 | |
| 854 | bool |
| 855 | Node::replaceInputInternal(const NodePtr& input, int inputNumber, bool useGuiInputs) |
| 856 | { |
| 857 | assert(_imp->inputsInitialized); |
| 858 | assert(input); |
| 859 | ///Check for cycles: they are forbidden in the graph |
| 860 | if ( !checkIfConnectingInputIsOk( input.get() ) ) { |
| 861 | return false; |
| 862 | } |
| 863 | if ( _imp->effect->isInputRotoBrush(inputNumber) ) { |
| 864 | qDebug() << "Debug: Attempt to connect " << input->getScriptName_mt_safe().c_str() << " to Roto brush"; |
| 865 | |
| 866 | return false; |
| 867 | } |
| 868 | |
| 869 | ///For effects that do not support multi-resolution, make sure the input effect is correct |
| 870 | ///otherwise the rendering might crash |
| 871 | if ( !_imp->effect->supportsMultiResolution() ) { |
| 872 | CanConnectInputReturnValue ret = checkCanConnectNoMultiRes(this, input); |
| 873 | if (ret != eCanConnectInput_ok) { |
| 874 | return false; |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | { |
| 879 | ///Check for invalid index |
| 880 | QMutexLocker l(&_imp->inputsMutex); |
| 881 | if ( (inputNumber < 0) || ( inputNumber > (int)_imp->inputs.size() ) ) { |
| 882 | return false; |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | { |
| 887 | QMutexLocker l(&_imp->inputsMutex); |
| 888 | ///Set the input |
| 889 | |
| 890 | if (!useGuiInputs) { |
| 891 | NodePtr curIn = _imp->inputs[inputNumber].lock(); |
| 892 | if (curIn) { |
| 893 | QObject::connect( curIn.get(), SIGNAL(labelChanged(QString)), this, SLOT(onInputLabelChanged(QString)) ); |
| 894 | curIn->disconnectOutput(useGuiInputs, this); |
| 895 | } |
| 896 | _imp->inputs[inputNumber] = input; |
| 897 | _imp->guiInputs[inputNumber] = input; |
| 898 | } else { |
| 899 | NodePtr curIn = _imp->guiInputs[inputNumber].lock(); |
| 900 | if (curIn) { |
| 901 | QObject::connect( curIn.get(), SIGNAL(labelChanged(QString)), this, SLOT(onInputLabelChanged(QString)) ); |
| 902 | curIn->disconnectOutput(useGuiInputs, this); |
| 903 | } |
| 904 | _imp->guiInputs[inputNumber] = input; |
| 905 | } |
| 906 | input->connectOutput( useGuiInputs, shared_from_this() ); |
| 907 | } |
| 908 | |
| 909 | ///Get notified when the input name has changed |
| 910 | QObject::connect( input.get(), SIGNAL(labelChanged(QString)), this, SLOT(onInputLabelChanged(QString)) ); |
| 911 |
no test coverage detected