Ignore:
Timestamp:
02/11/14 14:31:14 (9 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
b02e573
Parents:
a4c888d
Message:

Couple quick fixes to the life-preserver tray:
1) Make sure that the new single-instance functionality will not startup a prompt to open the main GUI for 30 seconds after the tray gets launched. This prevents "double-taps" on user login when the DE also starts up an instance automatically.
2) Whenever the system check timer goes off, also check that the lpreserver log file is being watched, and re-initialize the log file watcher if necessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/life-preserver/lp-tray/LPWatcher.cpp

    r6a2483b r9537cb2  
    3838  timer = new QTimer(); 
    3939    connect(timer, SIGNAL(timeout()), this, SLOT(checkPoolStatus()) ); 
     40  iniTimer = new QTimer(); 
     41    connect(iniTimer, SIGNAL(timeout()), this, SLOT(endInitPhase()) ); 
     42    iniTimer->setSingleShot(true); 
    4043  //initialize the log file reader 
    4144  logfile = new QFile(FILE_LOG, this); 
     
    5760// ----------------------------------- 
    5861void LPWatcher::start(){ 
    59   if(!logfile->exists()){ 
    60     QString dir = FILE_LOG; 
    61           dir.chop( dir.section("/",-1).count()+1 ); 
    62     if(!QFile::exists(dir)){ system( QString("mkdir -p "+dir).toUtf8() ); } 
    63     system( QString("touch "+FILE_LOG).toUtf8() ); 
    64   } 
    65   //Read the current state of the log file 
    66   logfile->open(QIODevice::ReadOnly | QIODevice::Text); 
    67   readLogFile(true); //do this quietly the first time through 
    68   //Now start up the log file watcher 
    69   watcher->addPath(FILE_LOG); 
     62  INIT=true; 
     63  setupLogFile(); 
    7064  //Now check for any current errors in the LPbackend 
    7165  checkPoolStatus(); 
    7266  //And start up the error file watcher 
    7367  if(!timer->isActive()){ timer->start(sysCheckTime); } 
     68  iniTimer->start(30000); //30 seconds of initialization phase 
    7469} 
    7570 
     
    143138} 
    144139 
     140bool LPWatcher::initPhase(){ 
     141  return INIT; 
     142} 
    145143// ------------------------------------- 
    146144//    PRIVATE FUNCTIONS 
    147145// ------------------------------------- 
     146void LPWatcher::setupLogFile(){ 
     147 //Tray now has user permissions and cannot create files/dirs in /var 
     148 /*if(!logfile->exists()){ 
     149    QString dir = FILE_LOG; 
     150          dir.chop( dir.section("/",-1).count()+1 ); 
     151    if(!QFile::exists(dir)){ system( QString("mkdir -p "+dir).toUtf8() ); } 
     152    system( QString("touch "+FILE_LOG).toUtf8() ); 
     153  }*/ 
     154         
     155  //Read the current state of the log file 
     156  if(logfile->exists()){ 
     157    logfile->open(QIODevice::ReadOnly | QIODevice::Text); 
     158    readLogFile(true); //do this quietly the first time through 
     159    //Now start up the log file watcher 
     160    watcher->addPath(FILE_LOG);  
     161  } 
     162} 
     163 
    148164void LPWatcher::readLogFile(bool quiet){ 
    149165  QStringList reppools = listReplicatedPools(); 
     
    386402 
    387403void LPWatcher::checkPoolStatus(){ 
     404  if(watcher->files().isEmpty()){ 
     405    setupLogFile(); //try it now - might have been created in the meantime 
     406  } 
    388407  //Now check zpool status for bad/running statuses 
    389408  QStringList zstat = getCmdOutput("zpool status"); 
     
    579598  else{ emit StatusUpdated(); } 
    580599} 
     600 
     601void LPWatcher::endInitPhase(){ 
     602  INIT=false; 
     603} 
Note: See TracChangeset for help on using the changeset viewer.