MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / replaceInputInternal

Method replaceInputInternal

Engine/NodeInputs.cpp:854–940  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

852}
853
854bool
855Node::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

Callers 1

deactivateMethod · 0.80

Calls 14

getAppFunction · 0.85
isInputRotoBrushMethod · 0.80
disconnectOutputMethod · 0.80
connectOutputMethod · 0.80
isCreatingNodeTreeMethod · 0.80
emptyMethod · 0.80
getMethod · 0.45
getScriptName_mt_safeMethod · 0.45

Tested by

no test coverage detected