src/hbservers/hbthemeserver/hbthemeserverapplication.cpp
changeset 28 b7da29130b0e
parent 21 4633027730f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
   111             QString path = QLatin1String(HB_BUILD_DIR) + QDir::separator() + QLatin1String("lib");
   111             QString path = QLatin1String(HB_BUILD_DIR) + QDir::separator() + QLatin1String("lib");
   112             library.setFileName(QDir(path).filePath(name));
   112             library.setFileName(QDir(path).filePath(name));
   113             result = library.load();
   113             result = library.load();
   114         }
   114         }
   115     }
   115     }
   116 #ifdef THEME_SERVER_TRACES
       
   117     if (!result) {
   116     if (!result) {
   118         qDebug() << "loadLibrary():" << library.errorString();
   117         THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "Error: " << library.errorString();
   119     }
   118     }
   120 #endif
       
   121     return result;
   119     return result;
   122 }
   120 }
   123 
   121 
   124 bool HbThemeServerLocker::lock()
   122 bool HbThemeServerLocker::lock()
   125 {
   123 {
   128     Q_FOREVER {
   126     Q_FOREVER {
   129         lockState = mLock.acquire();
   127         lockState = mLock.acquire();
   130         if (lockState == Lock::Reserved) {
   128         if (lockState == Lock::Reserved) {
   131             // Process may be starting, wait for server object to be created
   129             // Process may be starting, wait for server object to be created
   132             if (serverExists()) {
   130             if (serverExists()) {
   133 #ifdef THEME_SERVER_TRACES
   131                 THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "server already exists.";
   134                 qDebug() << "HbThemeServerLocker::lock: serverExists";
       
   135 #endif
       
   136                 break;
   132                 break;
   137             } else {
   133             } else {
   138                 const TInt KTimeout = 100000; // 100 ms
   134                 const TInt KTimeout = 100000; // 100 ms
   139                 User::After(KTimeout);
   135                 User::After(KTimeout);
   140             }
   136             }
   143         }
   139         }
   144     }
   140     }
   145     
   141     
   146     if (lockState != Lock::Acquired) {
   142     if (lockState != Lock::Acquired) {
   147         // With KErrAlreadyExists client should try to connect, otherwise bail out.
   143         // With KErrAlreadyExists client should try to connect, otherwise bail out.
   148 #ifdef THEME_SERVER_TRACES
   144         THEME_GENERIC_DEBUG() << Q_FUNC_INFO << "Lock not acquired.";
   149         qDebug() << "HbThemeServer::main: Lock not acquired!!!";
       
   150 #endif
       
   151         RProcess::Rendezvous(lockState == Lock::Reserved ? KErrAlreadyExists : KErrGeneral);
   145         RProcess::Rendezvous(lockState == Lock::Reserved ? KErrAlreadyExists : KErrGeneral);
   152     }
   146     }
   153 
   147 
   154     return (lockState == Lock::Acquired);
   148     return (lockState == Lock::Acquired);
   155 }
   149 }