Skip to content

Commit

Permalink
bug fix: fixed race condition in FFMPEGMovie global state init
Browse files Browse the repository at this point in the history
also fixed a segfault when attempting to move an invalid window to front
  • Loading branch information
ppodhajski authored and Raphael Dumusc committed Jan 26, 2017
1 parent 16c005d commit b6f0a7f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Raphael Dumusc <[email protected]>

cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(Tide VERSION 1.2.1)
project(Tide VERSION 1.2.2)
set(Tide_VERSION_ABI 1)

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake
Expand Down
6 changes: 6 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog {#changelog}
============

# Release 1.2.2 (25-01-2017)

* [116](https://github.com/BlueBrain/Tide/pull/116):
Bugfix: the application could crash when opening a session containing
multiple video files for the first time.

# Release 1.2.1 (16-12-2016)

* [113](https://github.com/BlueBrain/Tide/pull/113):
Expand Down
29 changes: 12 additions & 17 deletions tide/core/data/FFMPEGMovie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,21 @@ int ffmpegLockManagerCallback( void** mutex, enum AVLockOp op )
}
}

struct FFMPEGStaticInit
{
FFMPEGStaticInit()
{
av_lockmgr_register( &ffmpegLockManagerCallback );
av_register_all();
}
};
static FFMPEGStaticInit instance;

FFMPEGMovie::FFMPEGMovie( const QString& uri )
: _avFormatContext( 0 )
, _streamPosition( 0.0 )
, _isValid( false )
{
FFMPEGMovie::initGlobalState();
_isValid = _open( uri );
}
, _isValid( _open( uri ))
{}

FFMPEGMovie::~FFMPEGMovie()
{
Expand Down Expand Up @@ -139,18 +146,6 @@ void FFMPEGMovie::_releaseAvFormatContext()
avformat_close_input( &_avFormatContext );
}

void FFMPEGMovie::initGlobalState()
{
static bool initialized = false;

if( !initialized )
{
av_lockmgr_register( &ffmpegLockManagerCallback );
av_register_all();
initialized = true;
}
}

bool FFMPEGMovie::isValid() const
{
return _isValid;
Expand Down
3 changes: 0 additions & 3 deletions tide/core/data/FFMPEGMovie.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@ class FFMPEGMovie
double _streamPosition;
bool _isValid;

/** Init the global FFMPEG context. */
static void initGlobalState();

bool _open( const QString& uri );
bool _createAvFormatContext( const QString& uri );
void _releaseAvFormatContext();
Expand Down
2 changes: 1 addition & 1 deletion tide/master/control/DisplayGroupController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void DisplayGroupController::hidePanels()
void DisplayGroupController::moveWindowToFront( const QUuid id )
{
const auto window = _group.getContentWindow( id );
if( window->getMode() == ContentWindow::WindowMode::STANDARD )
if( window && window->getMode() == ContentWindow::WindowMode::STANDARD )
_group.moveToFront( window );
}

Expand Down

0 comments on commit b6f0a7f

Please sign in to comment.