| 363 | } |
| 364 | |
| 365 | bool |
| 366 | TrackMarker::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 | |
| 408 | std::string |
| 409 | TrackMarker::getScriptName_mt_safe() const |
nothing calls this directly
no test coverage detected