VirtualBox

Changeset 3859 in vbox for trunk


Ignore:
Timestamp:
Jul 26, 2007 8:56:24 AM (18 years ago)
Author:
vboxsync
Message:

FE/Qt: Attempted to workaround the unwanted assertion (see comment 19 in defect 2126).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r3806 r3859  
    837837 *                  Otherwise, a real type of the given image is returned
    838838 *                  (with the exception mentioned above).
     839 *
     840 *  @note The hard disk object may become uninitialized by a third party
     841 *  while this method is reading its properties. In this case, the method will
     842 *  return an empty string.
    839843 */
    840844QString VBoxGlobal::details (const CHardDisk &aHD, bool aPredict /* = false */)
     
    852856
    853857    CHardDisk root = aHD.GetRoot();
     858
     859    // @todo *** this check is rough; if aHD becomes uninitialized, any of aHD
     860    // getters called afterwards will also fail. The same relates to the root
     861    // object (that will be aHD itself in case of non-differencing
     862    // disks). However, this check was added to fix a particular use case:
     863    // when aHD is a differencing hard disk and it happens to be discarded
     864    // (and uninitialized) after this method is called but before we read all
     865    // its properties (yes, it's possible!), the root object will be null and
     866    // calling methods on it will assert in the debug builds. This check seems
     867    // to be enough as a quick solution (fresh hard disk attachments will be
     868    // re-read by a state change signal after the discard operation is
     869    // finished, so the user will eventually see correct data), but in order
     870    // to solve the problem properly we need to use exceptions everywhere (or
     871    // check the result after every method call). See also Comment #17 and
     872    // below in Defect #2126.
     873    if (!aHD.isOk())
     874        return QString::null;
     875
    854876    QString details;
    855877
     
    10411063            CHardDiskAttachment hda = aen.GetNext();
    10421064            CHardDisk hd = hda.GetHardDisk();
    1043             QString src = hd.GetRoot().GetLocation();
    1044             hardDisks += QString (sSectionItemTpl)
    1045                 .arg (QString ("%1 %2")
    1046                     .arg (toString (hda.GetController()))
    1047                     .arg (toString (hda.GetController(), hda.GetDeviceNumber())))
    1048                 .arg (QString ("%1 [<nobr>%2</nobr>]")
    1049                     .arg (prepareFileNameForHTML (src))
    1050                     .arg (details (hd, isNewVM /* predict */)));
    1051             ++ rows;
     1065            /// @todo for the explaination of the below isOk() checks, see
     1066            /// @todo *** in #details (const CHardDisk &, bool).
     1067            if (hda.isOk())
     1068            {
     1069                CHardDisk root = hd.GetRoot();
     1070                if (hd.isOk())
     1071                {
     1072                    QString src = root.GetLocation();
     1073                    hardDisks += QString (sSectionItemTpl)
     1074                        .arg (QString ("%1 %2")
     1075                              .arg (toString (hda.GetController()))
     1076                              .arg (toString (hda.GetController(),
     1077                                              hda.GetDeviceNumber())))
     1078                        .arg (QString ("%1 [<nobr>%2</nobr>]")
     1079                              .arg (prepareFileNameForHTML (src))
     1080                              .arg (details (hd, isNewVM /* predict */)));
     1081                    ++ rows;
     1082                }
     1083            }
    10521084        }
    10531085
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette