VirtualBox

Changeset 14706

Show
Ignore:
Timestamp:
11/27/08 15:25:54 (1 month ago)
Author:
vboxsync
Message:

Fe/Qt4: Systray: Added reference count for main windows.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxDefs.h

    r14578 r14706  
    155155#ifdef VBOX_GUI_WITH_SYSTRAY 
    156156    static const char* GUI_TrayIconWinID; 
     157    static const char* GUI_MainWindowCount; 
    157158#endif 
    158159}; 
  • trunk/src/VBox/Frontends/VirtualBox4/include/VBoxGlobal.h

    r14692 r14706  
    812812    } 
    813813 
    814     /* Returns the number of current running machines. */ 
    815     int machinesAlive() const
     814    /* Returns the number of current running Fe/Qt4 main windows. */ 
     815    int mainWindowCount()
    816816 
    817817    /* various helpers */ 
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxDefs.cpp

    r14578 r14706  
    4646const char* VBoxDefs::GUI_InfoDlgState = "GUI/InfoDlgState"; 
    4747#ifdef VBOX_GUI_WITH_SYSTRAY 
    48 const char* VBoxDefs::GUI_TrayIconWinID = "GUI/TrayIconWinID"; 
     48const char* VBoxDefs::GUI_TrayIconWinID = "GUI/TrayIcon/WinID"; 
     49const char* VBoxDefs::GUI_MainWindowCount = "GUI/MainWindowCount"; 
    4950#endif 
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxGlobal.cpp

    r14701 r14706  
    14401440        bActive = vboxGlobal().settings().trayIconEnabled(); 
    14411441 
    1442     QString strTrayWinID = virtualBox().GetExtraData (VBoxDefs::GUI_TrayIconWinID); 
     1442    /* Is there already a tray icon or is tray icon not active? */ 
     1443    QString strTrayWinID = mVBox.GetExtraData (VBoxDefs::GUI_TrayIconWinID); 
    14431444    if (   (bActive == false) 
    14441445        || (QSystemTrayIcon::isSystemTrayAvailable() == false) 
     
    31833184 
    31843185/** 
    3185  *  Returns the number of current running VMs. 
    3186  * 
    3187  *  @return Number of running VMs. 
    3188  */ 
    3189 int VBoxGlobal::machinesAlive () const 
    3190 
    3191     int machinesAlive = 0; 
    3192     CVirtualBox vbox = vboxGlobal().virtualBox(); 
    3193     CMachineVector vec = vbox.GetMachines2(); 
    3194     for (CMachineVector::ConstIterator m = vec.begin(); 
    3195         m != vec.end(); ++ m) 
    3196     { 
    3197         switch ((*m).GetState()) 
    3198         { 
    3199             case MachineState_Running: 
    3200             case MachineState_Paused: 
    3201             { 
    3202                 machinesAlive++; 
    3203                 break; 
    3204             } 
    3205         } 
    3206     } 
    3207  
    3208     return machinesAlive; 
     3186 *  Returns the number of current running Fe/Qt4 main windows. 
     3187 * 
     3188 *  @return Number of running main windows. 
     3189 */ 
     3190int VBoxGlobal::mainWindowCount () 
     3191
     3192    return mVBox.GetExtraData (VBoxDefs::GUI_MainWindowCount).toInt(); 
    32093193} 
    32103194 
     
    52815265        return; 
    52825266    } 
     5267 
     5268#ifdef VBOX_GUI_WITH_SYSTRAY 
     5269    /* Increase open Fe/Qt4 windows reference count. */ 
     5270    int c = mVBox.GetExtraData (VBoxDefs::GUI_MainWindowCount).toInt() + 1; 
     5271    AssertMsg ((c>=0) || (mVBox.isOk()), 
     5272        ("Something went wrong with the window reference count!")); 
     5273    mVBox.SetExtraData (VBoxDefs::GUI_MainWindowCount, QString ("%1").arg (c)); 
     5274#endif 
    52835275 
    52845276    /* Initialize guest OS Type list */ 
     
    55945586        delete mSelectorWnd; 
    55955587 
     5588#ifdef VBOX_GUI_WITH_SYSTRAY 
     5589    /* Decrease open Fe/Qt4 windows reference count. */ 
     5590    int c = mVBox.GetExtraData (VBoxDefs::GUI_MainWindowCount).toInt() - 1; 
     5591    AssertMsg ((c>=0) || (mVBox.isOk()), 
     5592        ("Something went wrong with the window reference count!")); 
     5593    if (c < 0) 
     5594        c = 0;   /* Clean up the mess. */ 
     5595    mVBox.SetExtraData (VBoxDefs::GUI_MainWindowCount, (c > 0) ? QString ("%1").arg (c) : NULL); 
     5596#endif 
     5597 
    55965598    /* ensure CGuestOSType objects are no longer used */ 
    55975599    mFamilyIDs.clear(); 
  • trunk/src/VBox/Frontends/VirtualBox4/src/VBoxSelectorWnd.cpp

    r14693 r14706  
    12051205    { 
    12061206        hide(); 
    1207         if (vboxGlobal().machinesAlive() == 0) 
     1207        if (vboxGlobal().mainWindowCount() == 0) 
    12081208        { 
    12091209            emit closing(); 
     
    15711571        /* Check if there are some machines alive - else quit, since 
    15721572         * we're not needed as a systray menu anymore. */ 
    1573         if (vboxGlobal().machinesAlive() == 0) 
     1573        if (vboxGlobal().mainWindowCount() == 0) 
    15741574        { 
    15751575            fileExit(); 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy