- don't delete the null logger.
- don't leak LogStreamInfo when detaching streams from DefaultLogger. - detach the stream before deleting it in aiDetachAllLogStreams. Thanks to Bart Botta for the patch. - DefaultLogger does not properly delete log streams if they're still attached to it when the logger is destroyed. This is the behaviour specified in the documentation. - Adapt AssimpView's logger usage, which didn't follow the spec as well. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@659 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
616bd39b6f
commit
bcf0ddc086
|
@ -486,7 +486,9 @@ ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream)
|
||||||
if( it == gActiveLogStreams.end()) {
|
if( it == gActiveLogStreams.end()) {
|
||||||
return AI_FAILURE;
|
return AI_FAILURE;
|
||||||
}
|
}
|
||||||
|
DefaultLogger::get()->detatchStream( it->second );
|
||||||
delete it->second;
|
delete it->second;
|
||||||
|
|
||||||
gActiveLogStreams.erase( it);
|
gActiveLogStreams.erase( it);
|
||||||
|
|
||||||
if (gActiveLogStreams.empty()) {
|
if (gActiveLogStreams.empty()) {
|
||||||
|
@ -504,6 +506,7 @@ ASSIMP_API void aiDetachAllLogStreams(void)
|
||||||
boost::mutex::scoped_lock lock(gLogStreamMutex);
|
boost::mutex::scoped_lock lock(gLogStreamMutex);
|
||||||
#endif
|
#endif
|
||||||
for (LogStreamMap::iterator it = gActiveLogStreams.begin(); it != gActiveLogStreams.end(); ++it) {
|
for (LogStreamMap::iterator it = gActiveLogStreams.begin(); it != gActiveLogStreams.end(); ++it) {
|
||||||
|
DefaultLogger::get()->detatchStream( it->second );
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
gActiveLogStreams.clear();
|
gActiveLogStreams.clear();
|
||||||
|
|
|
@ -82,7 +82,7 @@ struct LogStreamInfo
|
||||||
// Destructor
|
// Destructor
|
||||||
~LogStreamInfo()
|
~LogStreamInfo()
|
||||||
{
|
{
|
||||||
// empty
|
delete m_pStream;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -237,7 +237,7 @@ void DefaultLogger::kill()
|
||||||
boost::mutex::scoped_lock lock(loggerMutex);
|
boost::mutex::scoped_lock lock(loggerMutex);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_pLogger != &s_pNullLogger)return;
|
if (m_pLogger == &s_pNullLogger)return;
|
||||||
delete m_pLogger;
|
delete m_pLogger;
|
||||||
m_pLogger = &s_pNullLogger;
|
m_pLogger = &s_pNullLogger;
|
||||||
}
|
}
|
||||||
|
@ -332,6 +332,9 @@ bool DefaultLogger::detatchStream( LogStream *pStream, unsigned int severity )
|
||||||
(*it)->m_uiErrorSeverity &= ~severity;
|
(*it)->m_uiErrorSeverity &= ~severity;
|
||||||
if ( (*it)->m_uiErrorSeverity == 0 )
|
if ( (*it)->m_uiErrorSeverity == 0 )
|
||||||
{
|
{
|
||||||
|
// don't delete the underlying stream 'cause the caller gains ownership again
|
||||||
|
(**it).m_pStream = NULL;
|
||||||
|
delete *it;
|
||||||
m_StreamArray.erase( it );
|
m_StreamArray.erase( it );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -356,8 +359,10 @@ DefaultLogger::DefaultLogger(LogSeverity severity)
|
||||||
// Destructor
|
// Destructor
|
||||||
DefaultLogger::~DefaultLogger()
|
DefaultLogger::~DefaultLogger()
|
||||||
{
|
{
|
||||||
for ( StreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it )
|
for ( StreamIt it = m_StreamArray.begin(); it != m_StreamArray.end(); ++it ) {
|
||||||
|
// also frees the underlying stream, we are its owner.
|
||||||
delete *it;
|
delete *it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------
|
||||||
|
|
|
@ -124,8 +124,8 @@ public:
|
||||||
/** @brief Attach a new logstream
|
/** @brief Attach a new logstream
|
||||||
*
|
*
|
||||||
* The logger takes ownership of the stream and is responsible
|
* The logger takes ownership of the stream and is responsible
|
||||||
* for its destruction (which is done when the logger itself
|
* for its destruction (which is done using ::delete when the logger
|
||||||
* is destroyed). Call detachStream to detach a stream and to
|
* itself is destroyed). Call detachStream to detach a stream and to
|
||||||
* gain ownership of it again.
|
* gain ownership of it again.
|
||||||
* @param pStream Logstream to attach
|
* @param pStream Logstream to attach
|
||||||
* @param severity Message filter, specified which types of log
|
* @param severity Message filter, specified which types of log
|
||||||
|
|
|
@ -48,7 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* log window.
|
* log window.
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------
|
||||||
class CMyLogStream : Assimp::LogStream
|
class CMyLogStream : public Assimp::LogStream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** @brief Implementation of the abstract method */
|
/** @brief Implementation of the abstract method */
|
||||||
|
@ -122,7 +122,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// associated log stream
|
// associated log stream
|
||||||
CMyLogStream pcStream;
|
CMyLogStream* pcStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AV_LOG_DISPLA
|
#endif // AV_LOG_DISPLA
|
|
@ -2214,7 +2214,9 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||||
|
|
||||||
// initialise the default logger if neccessary
|
// initialise the default logger if neccessary
|
||||||
Assimp::DefaultLogger::create("",Assimp::Logger::VERBOSE);
|
Assimp::DefaultLogger::create("",Assimp::Logger::VERBOSE);
|
||||||
Assimp::DefaultLogger::get()->attachStream((Assimp::LogStream*)&CLogWindow::Instance().pcStream,
|
|
||||||
|
CLogWindow::Instance().pcStream = new CMyLogStream();
|
||||||
|
Assimp::DefaultLogger::get()->attachStream(CLogWindow::Instance().pcStream,
|
||||||
Assimp::DefaultLogger::DEBUGGING | Assimp::DefaultLogger::INFO |
|
Assimp::DefaultLogger::DEBUGGING | Assimp::DefaultLogger::INFO |
|
||||||
Assimp::DefaultLogger::ERR | Assimp::DefaultLogger::WARN);
|
Assimp::DefaultLogger::ERR | Assimp::DefaultLogger::WARN);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue