| 680 | } |
| 681 | |
| 682 | void |
| 683 | Node::initNodeScriptName(const NodeSerialization* serialization, const QString& fixedName) |
| 684 | { |
| 685 | /* |
| 686 | If the serialization is not null, we are either pasting a node or loading it from a project. |
| 687 | */ |
| 688 | boost::shared_ptr<NodeCollection> group = getGroup(); |
| 689 | bool isMultiInstanceChild = false; |
| 690 | if ( !_imp->multiInstanceParentName.empty() ) { |
| 691 | isMultiInstanceChild = true; |
| 692 | } |
| 693 | |
| 694 | if (!fixedName.isEmpty()) { |
| 695 | |
| 696 | std::string baseName = fixedName.toStdString(); |
| 697 | std::string name = baseName; |
| 698 | int no = 1; |
| 699 | do { |
| 700 | if (no > 1) { |
| 701 | std::stringstream ss; |
| 702 | ss << baseName; |
| 703 | ss << '_'; |
| 704 | ss << no; |
| 705 | name = ss.str(); |
| 706 | } |
| 707 | ++no; |
| 708 | } while ( group && group->checkIfNodeNameExists(name, this) ); |
| 709 | |
| 710 | //This version of setScriptName will not error if the name is invalid or already taken |
| 711 | setScriptName_no_error_check(name); |
| 712 | |
| 713 | } else if (serialization) { |
| 714 | if ( group && !group->isCacheIDAlreadyTaken( serialization->getCacheID() ) ) { |
| 715 | QMutexLocker k(&_imp->nameMutex); |
| 716 | _imp->cacheID = serialization->getCacheID(); |
| 717 | } |
| 718 | const std::string& baseName = serialization->getNodeScriptName(); |
| 719 | std::string name = baseName; |
| 720 | int no = 1; |
| 721 | do { |
| 722 | if (no > 1) { |
| 723 | std::stringstream ss; |
| 724 | ss << baseName; |
| 725 | ss << '_'; |
| 726 | ss << no; |
| 727 | name = ss.str(); |
| 728 | } |
| 729 | ++no; |
| 730 | } while ( group && group->checkIfNodeNameExists(name, this) ); |
| 731 | |
| 732 | //This version of setScriptName will not error if the name is invalid or already taken |
| 733 | setScriptName_no_error_check(name); |
| 734 | setLabel( serialization->getNodeLabel() ); |
| 735 | |
| 736 | } else { |
| 737 | std::string name; |
| 738 | QString pluginLabel; |
| 739 | AppManager::AppTypeEnum appType = appPTR->getAppType(); |
no test coverage detected