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

Method setScriptName

Engine/TrackMarker.cpp:383–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

381}
382
383bool
384TrackMarker::setScriptName(const std::string& name)
385{
386 ///called on the main-thread only
387 assert( QThread::currentThread() == qApp->thread() );
388
389 if ( name.empty() ) {
390 return false;
391 }
392
393 std::string currentName;
394 {
395 QMutexLocker l(&_imp->trackMutex);
396 currentName = _imp->trackScriptName;
397 }
398
399
400 std::string cpy = NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly(name);
401
402 if ( cpy.empty() || cpy == currentName) {
403 return false;
404 }
405
406 TrackMarkerPtr existingItem = getContext()->getMarkerByName(name);
407 if ( existingItem && (existingItem.get() != this) ) {
408 return false;
409 }
410
411 TrackMarkerPtr thisShared = shared_from_this();
412 if (!currentName.empty()) {
413 getContext()->removeItemAsPythonField(thisShared);
414 }
415
416 {
417 QMutexLocker l(&_imp->trackMutex);
418 _imp->trackScriptName = cpy;
419 }
420
421 getContext()->declareItemAsPythonField(thisShared);
422
423 return true;
424}
425
426std::string
427TrackMarker::getScriptName_mt_safe() const

Callers

nothing calls this directly

Calls 5

emptyMethod · 0.80
getMarkerByNameMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected