| 749 | } // Node::canConnectInput |
| 750 | |
| 751 | bool |
| 752 | Node::connectInput(const NodePtr & input, |
| 753 | int inputNumber) |
| 754 | { |
| 755 | assert(_imp->inputsInitialized); |
| 756 | assert(input); |
| 757 | |
| 758 | ///Check for cycles: they are forbidden in the graph |
| 759 | if ( !checkIfConnectingInputIsOk( input.get() ) ) { |
| 760 | return false; |
| 761 | } |
| 762 | if ( _imp->effect->isInputRotoBrush(inputNumber) ) { |
| 763 | qDebug() << "Debug: Attempt to connect " << input->getScriptName_mt_safe().c_str() << " to Roto brush"; |
| 764 | |
| 765 | return false; |
| 766 | } |
| 767 | |
| 768 | ///For effects that do not support multi-resolution, make sure the input effect is correct |
| 769 | ///otherwise the rendering might crash |
| 770 | if ( !_imp->effect->supportsMultiResolution() && !getApp()->getProject()->isLoadingProject() ) { |
| 771 | CanConnectInputReturnValue ret = checkCanConnectNoMultiRes(this, input); |
| 772 | if (ret != eCanConnectInput_ok) { |
| 773 | return false; |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | bool useGuiInputs = isNodeRendering(); |
| 778 | _imp->effect->abortAnyEvaluation(); |
| 779 | |
| 780 | { |
| 781 | ///Check for invalid index |
| 782 | QMutexLocker l(&_imp->inputsMutex); |
| 783 | if ( (inputNumber < 0) || |
| 784 | ( inputNumber >= (int)_imp->inputs.size() ) || |
| 785 | ( !useGuiInputs && _imp->inputs[inputNumber].lock() ) || |
| 786 | ( useGuiInputs && _imp->guiInputs[inputNumber].lock() ) ) { |
| 787 | return false; |
| 788 | } |
| 789 | |
| 790 | ///Set the input |
| 791 | if (!useGuiInputs) { |
| 792 | _imp->inputs[inputNumber] = input; |
| 793 | _imp->guiInputs[inputNumber] = input; |
| 794 | } else { |
| 795 | _imp->guiInputs[inputNumber] = input; |
| 796 | } |
| 797 | input->connectOutput( useGuiInputs, shared_from_this() ); |
| 798 | } |
| 799 | |
| 800 | getApp()->recheckInvalidExpressions(); |
| 801 | |
| 802 | ///Get notified when the input name has changed |
| 803 | QObject::connect( input.get(), SIGNAL(labelChanged(QString)), this, SLOT(onInputLabelChanged(QString)) ); |
| 804 | |
| 805 | ///Notify the GUI |
| 806 | Q_EMIT inputChanged(inputNumber); |
| 807 | bool mustCallEnd = false; |
| 808 |
nothing calls this directly
no test coverage detected