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

Method setScriptName

Engine/TrackMarker.cpp:365–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365bool
366TrackMarker::setScriptName(const std::string& name)
367{
368 ///called on the main-thread only
369 assert( QThread::currentThread() == qApp->thread() );
370
371 if ( name.empty() ) {
372 return false;
373 }
374
375 std::string currentName;
376 {
377 QMutexLocker l(&_imp->trackMutex);
378 currentName = _imp->trackScriptName;
379 }
380
381
382 std::string cpy = NATRON_PYTHON_NAMESPACE::makeNameScriptFriendly(name);
383
384 if ( cpy.empty() || cpy == currentName) {
385 return false;
386 }
387
388 TrackMarkerPtr existingItem = getContext()->getMarkerByName(name);
389 if ( existingItem && (existingItem.get() != this) ) {
390 return false;
391 }
392
393 TrackMarkerPtr thisShared = shared_from_this();
394 if (!currentName.empty()) {
395 getContext()->removeItemAsPythonField(thisShared);
396 }
397
398 {
399 QMutexLocker l(&_imp->trackMutex);
400 _imp->trackScriptName = cpy;
401 }
402
403 getContext()->declareItemAsPythonField(thisShared);
404
405 return true;
406}
407
408std::string
409TrackMarker::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