Fix indicator crash 05/133705/1
authorHeeyong Song <heeyong.song@samsung.com>
Tue, 13 Jun 2017 07:05:44 +0000 (16:05 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Tue, 13 Jun 2017 07:06:53 +0000 (16:06 +0900)
Change-Id: I16f27d7627eee4328d92e6ed2d7db8e59e90f79d

adaptors/ecore/common/ecore-indicator-impl.cpp

index 4ed4667..574e0bd 100644 (file)
@@ -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");
   }
 }