---------------------------------------------------------------------------------- Detach a stream
| 342 | // ---------------------------------------------------------------------------------- |
| 343 | // Detach a stream |
| 344 | bool DefaultLogger::detachStream(LogStream *pStream, unsigned int severity) { |
| 345 | if (nullptr == pStream) { |
| 346 | return false; |
| 347 | } |
| 348 | |
| 349 | if (0 == severity) { |
| 350 | severity = SeverityAll; |
| 351 | } |
| 352 | |
| 353 | #ifndef ASSIMP_BUILD_SINGLETHREADED |
| 354 | std::lock_guard<std::mutex> lock(m_arrayMutex); |
| 355 | #endif |
| 356 | |
| 357 | bool res(false); |
| 358 | for (StreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it) { |
| 359 | if ((*it)->m_pStream == pStream) { |
| 360 | (*it)->m_uiErrorSeverity &= ~severity; |
| 361 | if ((*it)->m_uiErrorSeverity == 0) { |
| 362 | // don't delete the underlying stream 'cause the caller gains ownership again |
| 363 | (**it).m_pStream = nullptr; |
| 364 | delete *it; |
| 365 | m_StreamArray.erase(it); |
| 366 | res = true; |
| 367 | break; |
| 368 | } |
| 369 | return true; |
| 370 | } |
| 371 | } |
| 372 | return res; |
| 373 | } |
| 374 | |
| 375 | // ---------------------------------------------------------------------------------- |
| 376 | // Constructor |
no test coverage detected