From 947713e1a33face353c1187925296ba3a596ddb3 Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Tue, 13 Jun 2017 16:05:44 +0900 Subject: [PATCH] Fix indicator crash Change-Id: I16f27d7627eee4328d92e6ed2d7db8e59e90f79d --- adaptors/ecore/common/ecore-indicator-impl.cpp | 43 +++++++++++++------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/adaptors/ecore/common/ecore-indicator-impl.cpp b/adaptors/ecore/common/ecore-indicator-impl.cpp index 4ed4667..574e0bd 100644 --- a/adaptors/ecore/common/ecore-indicator-impl.cpp +++ b/adaptors/ecore/common/ecore-indicator-impl.cpp @@ -468,7 +468,10 @@ Indicator::LockFile::LockFile(const std::string filename) Indicator::LockFile::~LockFile() { // Closing file descriptor also unlocks file. - close( mFileDescriptor ); + if( mFileDescriptor > 0 ) + { + close( mFileDescriptor ); + } } bool Indicator::LockFile::Lock() @@ -507,16 +510,19 @@ void Indicator::LockFile::Unlock() { DALI_LOG_TRACE_METHOD( gIndicatorLogFilter ); - struct flock filelock; - - filelock.l_type = F_UNLCK; - filelock.l_whence = SEEK_SET; - filelock.l_start = 0; - filelock.l_len = 0; - if (fcntl(mFileDescriptor, F_SETLKW, &filelock) == -1) + if( mFileDescriptor > 0 ) { - mErrorThrown = true; - DALI_LOG_ERROR( "### Failed to lock with fd : %s ###\n", mFilename.c_str() ); + struct flock filelock; + + filelock.l_type = F_UNLCK; + filelock.l_whence = SEEK_SET; + filelock.l_start = 0; + filelock.l_len = 0; + if (fcntl(mFileDescriptor, F_SETLKW, &filelock) == -1) + { + mErrorThrown = true; + DALI_LOG_ERROR( "### Failed to lock with fd : %s ###\n", mFilename.c_str() ); + } } } @@ -1055,9 +1061,11 @@ void Indicator::LoadSharedImage( Ecore_Ipc_Event_Server_Data *epcEvent ) { DALI_LOG_ERROR( "### Indicator error: Cannot open lock file %s ###\n", mSharedFileInfo[n].mLockFileName.c_str() ); } - - CreateNewImage( n ); - UpdateVisibility(); + else + { + CreateNewImage( n ); + UpdateVisibility(); + } } } } @@ -1212,14 +1220,7 @@ void Indicator::CreateNewImage( int bufferNumber ) if( !success ) { - DALI_LOG_WARNING("### Cannot create indicator image - disconnecting ###\n"); - Disconnect(); - if( mObserver != NULL ) - { - mObserver->IndicatorClosed( this ); - } - // Don't do connection in this callback - strange things happen! - StartReconnectionTimer(); + DALI_LOG_WARNING("### Cannot create indicator image ###\n"); } } -- 2.7.4