From 48e6c68c3072c162326d553d876ae5b80e76ee05 Mon Sep 17 00:00:00 2001 From: Pawel Podhajski Date: Tue, 24 Jan 2017 12:51:34 +0100 Subject: [PATCH] bug fix: fixed race condition in FFMPEGMovie global state init also fixed a segfault when attempting to move an invalid window to front --- CMakeLists.txt | 2 +- doc/Changelog.md | 6 ++++ tide/core/data/FFMPEGMovie.cpp | 29 ++++++++----------- tide/core/data/FFMPEGMovie.h | 3 -- .../master/control/DisplayGroupController.cpp | 2 +- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62f2bfcd..40602c6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # Raphael Dumusc 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 diff --git a/doc/Changelog.md b/doc/Changelog.md index 31ef3a20..08c83e25 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -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): diff --git a/tide/core/data/FFMPEGMovie.cpp b/tide/core/data/FFMPEGMovie.cpp index 073d089e..f1291301 100644 --- a/tide/core/data/FFMPEGMovie.cpp +++ b/tide/core/data/FFMPEGMovie.cpp @@ -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() { @@ -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; diff --git a/tide/core/data/FFMPEGMovie.h b/tide/core/data/FFMPEGMovie.h index 793bf7a8..5263e618 100644 --- a/tide/core/data/FFMPEGMovie.h +++ b/tide/core/data/FFMPEGMovie.h @@ -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(); diff --git a/tide/master/control/DisplayGroupController.cpp b/tide/master/control/DisplayGroupController.cpp index c92fb3ee..4284f99b 100644 --- a/tide/master/control/DisplayGroupController.cpp +++ b/tide/master/control/DisplayGroupController.cpp @@ -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 ); }