VirtualBox

Changeset 87268 in vbox for trunk


Ignore:
Timestamp:
Jan 15, 2021 12:50:01 PM (4 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9871: UIDetailsWidgetHostNetwork: A bit of paranoia, make sure widgets created before using them, useful for debugging with widgets partially disabled.

File:
1 edited

Legend:

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

    r87219 r87268  
    7575{
    7676    /* Translate tab-widget: */
    77     m_pTabWidget->setTabText(0, tr("&Adapter"));
    78     m_pTabWidget->setTabText(1, tr("&DHCP Server"));
     77    if (m_pTabWidget)
     78    {
     79        m_pTabWidget->setTabText(0, tr("&Adapter"));
     80        m_pTabWidget->setTabText(1, tr("&DHCP Server"));
     81    }
    7982
    8083    /* Translate 'Interface' tab content: */
    81     m_pButtonAutomatic->setText(tr("Configure Adapter &Automatically"));
    82     m_pButtonManual->setText(tr("Configure Adapter &Manually"));
    83     m_pLabelIPv4->setText(tr("&IPv4 Address:"));
    84     m_pEditorIPv4->setToolTip(tr("Holds the host IPv4 address for this adapter."));
    85     m_pLabelNMv4->setText(tr("IPv4 Network &Mask:"));
    86     m_pEditorNMv4->setToolTip(tr("Holds the host IPv4 network mask for this adapter."));
    87     m_pLabelIPv6->setText(tr("I&Pv6 Address:"));
    88     m_pEditorIPv6->setToolTip(tr("Holds the host IPv6 address for this adapter if IPv6 is supported."));
    89     m_pLabelNMv6->setText(tr("IPv6 Prefix &Length:"));
    90     m_pEditorNMv6->setToolTip(tr("Holds the host IPv6 prefix length for this adapter if IPv6 is supported."));
     84    if (m_pButtonAutomatic)
     85        m_pButtonAutomatic->setText(tr("Configure Adapter &Automatically"));
     86    if (m_pButtonManual)
     87        m_pButtonManual->setText(tr("Configure Adapter &Manually"));
     88    if (m_pLabelIPv4)
     89        m_pLabelIPv4->setText(tr("&IPv4 Address:"));
     90    if (m_pEditorIPv4)
     91        m_pEditorIPv4->setToolTip(tr("Holds the host IPv4 address for this adapter."));
     92    if (m_pLabelNMv4)
     93        m_pLabelNMv4->setText(tr("IPv4 Network &Mask:"));
     94    if (m_pEditorNMv4)
     95        m_pEditorNMv4->setToolTip(tr("Holds the host IPv4 network mask for this adapter."));
     96    if (m_pLabelIPv6)
     97        m_pLabelIPv6->setText(tr("I&Pv6 Address:"));
     98    if (m_pEditorIPv6)
     99        m_pEditorIPv6->setToolTip(tr("Holds the host IPv6 address for this adapter if IPv6 is supported."));
     100    if (m_pLabelNMv6)
     101        m_pLabelNMv6->setText(tr("IPv6 Prefix &Length:"));
     102    if (m_pEditorNMv6)
     103        m_pEditorNMv6->setToolTip(tr("Holds the host IPv6 prefix length for this adapter if IPv6 is supported."));
    91104    if (m_pButtonBoxInterface)
    92105    {
     
    104117
    105118    /* Translate 'DHCP server' tab content: */
    106     m_pCheckBoxDHCP->setText(tr("&Enable Server"));
    107     m_pCheckBoxDHCP->setToolTip(tr("When checked, the DHCP Server will be enabled for this network on machine start-up."));
    108     m_pLabelDHCPAddress->setText(tr("Server Add&ress:"));
    109     m_pEditorDHCPAddress->setToolTip(tr("Holds the address of the DHCP server servicing the network associated with this host-only adapter."));
    110     m_pLabelDHCPMask->setText(tr("Server &Mask:"));
    111     m_pEditorDHCPMask->setToolTip(tr("Holds the network mask of the DHCP server servicing the network associated with this host-only adapter."));
    112     m_pLabelDHCPLowerAddress->setText(tr("&Lower Address Bound:"));
    113     m_pEditorDHCPLowerAddress->setToolTip(tr("Holds the lower address bound offered by the DHCP server servicing the network associated with this host-only adapter."));
    114     m_pLabelDHCPUpperAddress->setText(tr("&Upper Address Bound:"));
    115     m_pEditorDHCPUpperAddress->setToolTip(tr("Holds the upper address bound offered by the DHCP server servicing the network associated with this host-only adapter."));
     119    if (m_pCheckBoxDHCP)
     120    {
     121        m_pCheckBoxDHCP->setText(tr("&Enable Server"));
     122        m_pCheckBoxDHCP->setToolTip(tr("When checked, the DHCP Server will be enabled for this network on machine start-up."));
     123    }
     124    if (m_pLabelDHCPAddress)
     125        m_pLabelDHCPAddress->setText(tr("Server Add&ress:"));
     126    if (m_pEditorDHCPAddress)
     127        m_pEditorDHCPAddress->setToolTip(tr("Holds the address of the DHCP server servicing the network associated with this host-only adapter."));
     128    if (m_pLabelDHCPMask)
     129        m_pLabelDHCPMask->setText(tr("Server &Mask:"));
     130    if (m_pEditorDHCPMask)
     131        m_pEditorDHCPMask->setToolTip(tr("Holds the network mask of the DHCP server servicing the network associated with this host-only adapter."));
     132    if (m_pLabelDHCPLowerAddress)
     133        m_pLabelDHCPLowerAddress->setText(tr("&Lower Address Bound:"));
     134    if (m_pEditorDHCPLowerAddress)
     135        m_pEditorDHCPLowerAddress->setToolTip(tr("Holds the lower address bound offered by the DHCP server servicing the network associated with this host-only adapter."));
     136    if (m_pLabelDHCPUpperAddress)
     137        m_pLabelDHCPUpperAddress->setText(tr("&Upper Address Bound:"));
     138    if (m_pEditorDHCPUpperAddress)
     139        m_pEditorDHCPUpperAddress->setToolTip(tr("Holds the upper address bound offered by the DHCP server servicing the network associated with this host-only adapter."));
    116140    if (m_pButtonBoxServer)
    117141    {
     
    214238void UIDetailsWidgetHostNetwork::sltHandleButtonBoxClick(QAbstractButton *pButton)
    215239{
    216     /* Make sure button-box exists: */
    217     AssertPtrReturnVoid(m_pButtonBoxInterface);
    218     AssertPtrReturnVoid(m_pButtonBoxServer);
     240    /* Make sure button-boxes exist: */
     241    if (!m_pButtonBoxInterface || !m_pButtonBoxServer)
     242        return;
    219243
    220244    /* Disable buttons first of all: */
     
    250274    /* Create layout: */
    251275    QVBoxLayout *pLayout = new QVBoxLayout(this);
    252     AssertPtrReturnVoid(pLayout);
     276    if (pLayout)
    253277    {
    254278        /* Configure layout: */
     
    264288    /* Create tab-widget: */
    265289    m_pTabWidget = new QITabWidget;
    266     AssertPtrReturnVoid(m_pTabWidget);
     290    if (m_pTabWidget)
    267291    {
    268292        /* Prepare 'Interface' tab: */
     
    280304    /* Create 'Interface' tab: */
    281305    QWidget *pTabInterface = new QWidget;
    282     AssertPtrReturnVoid(pTabInterface);
     306    if (pTabInterface)
    283307    {
    284308        /* Create 'Interface' layout: */
    285309        QGridLayout *pLayoutInterface = new QGridLayout(pTabInterface);
    286         AssertPtrReturnVoid(pLayoutInterface);
     310        if (pLayoutInterface)
    287311        {
    288312#ifdef VBOX_WS_MAC
     
    297321            /* Create automatic interface configuration layout: */
    298322            QHBoxLayout *pLayoutAutomatic = new QHBoxLayout;
    299             AssertPtrReturnVoid(pLayoutAutomatic);
     323            if (pLayoutAutomatic)
    300324            {
    301325                /* Configure layout: */
     
    304328                /* Create automatic interface configuration radio-button: */
    305329                m_pButtonAutomatic = new QRadioButton;
    306                 AssertPtrReturnVoid(m_pButtonAutomatic);
     330                if (m_pButtonAutomatic)
    307331                {
    308332                    /* Configure radio-button: */
     
    314338                /* Create automatic interface configuration error pane: */
    315339                m_pErrorPaneAutomatic = new QLabel;
    316                 AssertPtrReturnVoid(m_pErrorPaneAutomatic);
     340                if (m_pErrorPaneAutomatic)
    317341                {
    318342                    /* Configure label: */
     
    333357            /* Create manual interface configuration layout: */
    334358            QHBoxLayout *pLayoutManual = new QHBoxLayout;
    335             AssertPtrReturnVoid(pLayoutManual);
     359            if (pLayoutManual)
    336360            {
    337361                /* Configure layout: */
     
    339363                /* Create manual interface configuration radio-button: */
    340364                m_pButtonManual = new QRadioButton;
    341                 AssertPtrReturnVoid(m_pButtonManual);
     365                if (m_pButtonManual)
    342366                {
    343367                    /* Configure radio-button: */
     
    349373                /* Create manual interface configuration error pane: */
    350374                m_pErrorPaneManual = new QLabel;
    351                 AssertPtrReturnVoid(m_pErrorPaneManual);
     375                if (m_pErrorPaneManual)
    352376                {
    353377                    /* Configure label: */
     
    368392            /* Create IPv4 address label: */
    369393            m_pLabelIPv4 = new QLabel;
    370             AssertPtrReturnVoid(m_pLabelIPv4);
     394            if (m_pLabelIPv4)
    371395            {
    372396                /* Configure label: */
     
    377401            /* Create IPv4 layout: */
    378402            QHBoxLayout *pLayoutIPv4 = new QHBoxLayout;
    379             AssertPtrReturnVoid(pLayoutIPv4);
     403            if (pLayoutIPv4)
    380404            {
    381405                /* Configure layout: */
     
    383407                /* Create IPv4 address editor: */
    384408                m_pEditorIPv4 = new QILineEdit;
    385                 AssertPtrReturnVoid(m_pEditorIPv4);
     409                if (m_pEditorIPv4)
    386410                {
    387411                    /* Configure editor: */
     
    394418                /* Create IPv4 error pane: */
    395419                m_pErrorPaneIPv4 = new QLabel;
    396                 AssertPtrReturnVoid(m_pErrorPaneIPv4);
     420                if (m_pErrorPaneIPv4)
    397421                {
    398422                    /* Configure label: */
     
    409433            /* Create NMv4 network mask label: */
    410434            m_pLabelNMv4 = new QLabel;
    411             AssertPtrReturnVoid(m_pLabelNMv4);
     435            if (m_pLabelNMv4)
    412436            {
    413437                /* Configure label: */
     
    418442            /* Create NMv4 layout: */
    419443            QHBoxLayout *pLayoutNMv4 = new QHBoxLayout;
    420             AssertPtrReturnVoid(pLayoutNMv4);
     444            if (pLayoutNMv4)
    421445            {
    422446                /* Configure layout: */
     
    424448                /* Create NMv4 network mask editor: */
    425449                m_pEditorNMv4 = new QILineEdit;
    426                 AssertPtrReturnVoid(m_pEditorNMv4);
     450                if (m_pEditorNMv4)
    427451                {
    428452                    /* Configure editor: */
     
    435459                /* Create NMv4 error pane: */
    436460                m_pErrorPaneNMv4 = new QLabel;
    437                 AssertPtrReturnVoid(m_pErrorPaneNMv4);
     461                if (m_pErrorPaneNMv4)
    438462                {
    439463                    /* Configure label: */
     
    450474            /* Create IPv6 address label: */
    451475            m_pLabelIPv6 = new QLabel;
    452             AssertPtrReturnVoid(m_pLabelIPv6);
     476            if (m_pLabelIPv6)
    453477            {
    454478                /* Configure label: */
     
    459483            /* Create IPv6 layout: */
    460484            QHBoxLayout *pLayoutIPv6 = new QHBoxLayout;
    461             AssertPtrReturnVoid(pLayoutIPv6);
     485            if (pLayoutIPv6)
    462486            {
    463487                /* Configure layout: */
     
    465489                /* Create IPv6 address editor: */
    466490                m_pEditorIPv6 = new QILineEdit;
    467                 AssertPtrReturnVoid(m_pEditorIPv6);
     491                if (m_pEditorIPv6)
    468492                {
    469493                    /* Configure editor: */
     
    476500                /* Create IPv4 error pane: */
    477501                m_pErrorPaneIPv6 = new QLabel;
    478                 AssertPtrReturnVoid(m_pErrorPaneIPv6);
     502                if (m_pErrorPaneIPv6)
    479503                {
    480504                    /* Configure label: */
     
    491515            /* Create NMv6 network mask label: */
    492516            m_pLabelNMv6 = new QLabel;
    493             AssertPtrReturnVoid(m_pLabelNMv6);
     517            if (m_pLabelNMv6)
    494518            {
    495519                /* Configure label: */
     
    500524            /* Create NMv6 layout: */
    501525            QHBoxLayout *pLayoutNMv6 = new QHBoxLayout;
    502             AssertPtrReturnVoid(pLayoutNMv6);
     526            if (pLayoutNMv6)
    503527            {
    504528                /* Configure layout: */
     
    506530                /* Create NMv6 network mask editor: */
    507531                m_pEditorNMv6 = new QILineEdit;
    508                 AssertPtrReturnVoid(m_pEditorNMv6);
     532                if (m_pEditorNMv6)
    509533                {
    510534                    /* Configure editor: */
     
    517541                /* Create NMv6 error pane: */
    518542                m_pErrorPaneNMv6 = new QLabel;
    519                 AssertPtrReturnVoid(m_pErrorPaneNMv6);
     543                if (m_pErrorPaneNMv6)
    520544                {
    521545                    /* Configure label: */
     
    537561                               pLayoutInterface->spacing() - 1;
    538562            QSpacerItem *pSpacer1 = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
    539             AssertPtrReturnVoid(pSpacer1);
     563            if (pSpacer1)
    540564            {
    541565                /* Add into layout: */
     
    544568            /* Create stretch: */
    545569            QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    546             AssertPtrReturnVoid(pSpacer2);
     570            if (pSpacer2)
    547571            {
    548572                /* Add into layout: */
     
    555579                /* Create button-box: */
    556580                m_pButtonBoxInterface = new QIDialogButtonBox;
    557                 AssertPtrReturnVoid(m_pButtonBoxInterface);
    558                 /* Configure button-box: */
    559                 m_pButtonBoxInterface->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    560                 connect(m_pButtonBoxInterface, &QIDialogButtonBox::clicked, this, &UIDetailsWidgetHostNetwork::sltHandleButtonBoxClick);
    561 
    562                 /* Add into layout: */
    563                 pLayoutInterface->addWidget(m_pButtonBoxInterface, 7, 0, 1, 3);
     581                if (m_pButtonBoxInterface)
     582                {
     583                    /* Configure button-box: */
     584                    m_pButtonBoxInterface->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
     585                    connect(m_pButtonBoxInterface, &QIDialogButtonBox::clicked, this, &UIDetailsWidgetHostNetwork::sltHandleButtonBoxClick);
     586
     587                    /* Add into layout: */
     588                    pLayoutInterface->addWidget(m_pButtonBoxInterface, 7, 0, 1, 3);
     589                }
    564590            }
    565591        }
     
    573599    /* Create 'DHCP server' tab: */
    574600    QWidget *pTabDHCPServer = new QWidget;
    575     AssertPtrReturnVoid(pTabDHCPServer);
     601    if (pTabDHCPServer)
    576602    {
    577603        /* Create 'DHCP server' layout: */
    578604        QGridLayout *pLayoutDHCPServer = new QGridLayout(pTabDHCPServer);
    579         AssertPtrReturnVoid(pLayoutDHCPServer);
     605        if (pLayoutDHCPServer)
    580606        {
    581607#ifdef VBOX_WS_MAC
     
    590616            /* Create DHCP server status check-box: */
    591617            m_pCheckBoxDHCP = new QCheckBox;
    592             AssertPtrReturnVoid(m_pCheckBoxDHCP);
     618            if (m_pCheckBoxDHCP)
    593619            {
    594620                /* Configure check-box: */
     
    604630            /* Create DHCP address label: */
    605631            m_pLabelDHCPAddress = new QLabel;
    606             AssertPtrReturnVoid(m_pLabelDHCPAddress);
     632            if (m_pLabelDHCPAddress)
    607633            {
    608634                /* Configure label: */
     
    613639            /* Create DHCP address layout: */
    614640            QHBoxLayout *pLayoutDHCPAddress = new QHBoxLayout;
    615             AssertPtrReturnVoid(pLayoutDHCPAddress);
     641            if (pLayoutDHCPAddress)
    616642            {
    617643                /* Configure layout: */
     
    619645                /* Create DHCP address editor: */
    620646                m_pEditorDHCPAddress = new QILineEdit;
    621                 AssertPtrReturnVoid(m_pEditorDHCPAddress);
     647                if (m_pEditorDHCPAddress)
    622648                {
    623649                    /* Configure editor: */
     
    630656                /* Create DHCP address error pane: */
    631657                m_pErrorPaneDHCPAddress = new QLabel;
    632                 AssertPtrReturnVoid(m_pErrorPaneDHCPAddress);
     658                if (m_pErrorPaneDHCPAddress)
    633659                {
    634660                    /* Configure label: */
     
    645671            /* Create DHCP network mask label: */
    646672            m_pLabelDHCPMask = new QLabel;
    647             AssertPtrReturnVoid(m_pLabelDHCPMask);
     673            if (m_pLabelDHCPMask)
    648674            {
    649675                /* Configure label: */
     
    654680            /* Create DHCP mask layout: */
    655681            QHBoxLayout *pLayoutDHCPMask = new QHBoxLayout;
    656             AssertPtrReturnVoid(pLayoutDHCPMask);
     682            if (pLayoutDHCPMask)
    657683            {
    658684                /* Configure layout: */
     
    660686                /* Create DHCP network mask editor: */
    661687                m_pEditorDHCPMask = new QILineEdit;
    662                 AssertPtrReturnVoid(m_pEditorDHCPMask);
     688                if (m_pEditorDHCPMask)
    663689                {
    664690                    /* Configure editor: */
     
    671697                /* Create DHCP mask error pane: */
    672698                m_pErrorPaneDHCPMask = new QLabel;
    673                 AssertPtrReturnVoid(m_pErrorPaneDHCPMask);
     699                if (m_pErrorPaneDHCPMask)
    674700                {
    675701                    /* Configure label: */
     
    686712            /* Create DHCP lower address label: */
    687713            m_pLabelDHCPLowerAddress = new QLabel;
    688             AssertPtrReturnVoid(m_pLabelDHCPLowerAddress);
     714            if (m_pLabelDHCPLowerAddress)
    689715            {
    690716                /* Configure label: */
     
    695721            /* Create DHCP lower address layout: */
    696722            QHBoxLayout *pLayoutDHCPLowerAddress = new QHBoxLayout;
    697             AssertPtrReturnVoid(pLayoutDHCPLowerAddress);
     723            if (pLayoutDHCPLowerAddress)
    698724            {
    699725                /* Configure layout: */
     
    701727                /* Create DHCP lower address editor: */
    702728                m_pEditorDHCPLowerAddress = new QILineEdit;
    703                 AssertPtrReturnVoid(m_pEditorDHCPLowerAddress);
     729                if (m_pEditorDHCPLowerAddress)
    704730                {
    705731                    /* Configure editor: */
     
    712738                /* Create DHCP lower address error pane: */
    713739                m_pErrorPaneDHCPLowerAddress = new QLabel;
    714                 AssertPtrReturnVoid(m_pErrorPaneDHCPLowerAddress);
     740                if (m_pErrorPaneDHCPLowerAddress)
    715741                {
    716742                    /* Configure label: */
     
    727753            /* Create DHCP upper address label: */
    728754            m_pLabelDHCPUpperAddress = new QLabel;
    729             AssertPtrReturnVoid(m_pLabelDHCPUpperAddress);
     755            if (m_pLabelDHCPUpperAddress)
    730756            {
    731757                /* Configure label: */
     
    736762            /* Create DHCP upper address layout: */
    737763            QHBoxLayout *pLayoutDHCPUpperAddress = new QHBoxLayout;
    738             AssertPtrReturnVoid(pLayoutDHCPUpperAddress);
     764            if (pLayoutDHCPUpperAddress)
    739765            {
    740766                /* Configure layout: */
     
    742768                /* Create DHCP upper address editor: */
    743769                m_pEditorDHCPUpperAddress = new QILineEdit;
    744                 AssertPtrReturnVoid(m_pEditorDHCPUpperAddress);
     770                if (m_pEditorDHCPUpperAddress)
    745771                {
    746772                    /* Configure editor: */
     
    753779                /* Create DHCP upper address error pane: */
    754780                m_pErrorPaneDHCPUpperAddress = new QLabel;
    755                 AssertPtrReturnVoid(m_pErrorPaneDHCPUpperAddress);
     781                if (m_pErrorPaneDHCPUpperAddress)
    756782                {
    757783                    /* Configure label: */
     
    773799                               pLayoutDHCPServer->spacing() - 1;
    774800            QSpacerItem *pSpacer1 = new QSpacerItem(iWidth, 0, QSizePolicy::Fixed, QSizePolicy::Expanding);
    775             AssertPtrReturnVoid(pSpacer1);
     801            if (pSpacer1)
    776802            {
    777803                /* Add into layout: */
     
    780806            /* Create stretch: */
    781807            QSpacerItem *pSpacer2 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
    782             AssertPtrReturnVoid(pSpacer2);
     808            if (pSpacer2)
    783809            {
    784810                /* Add into layout: */
     
    791817                /* Create button-box: */
    792818                m_pButtonBoxServer = new QIDialogButtonBox;
    793                 AssertPtrReturnVoid(m_pButtonBoxServer);
    794                 /* Configure button-box: */
    795                 m_pButtonBoxServer->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
    796                 connect(m_pButtonBoxServer, &QIDialogButtonBox::clicked, this, &UIDetailsWidgetHostNetwork::sltHandleButtonBoxClick);
    797 
    798                 /* Add into layout: */
    799                 pLayoutDHCPServer->addWidget(m_pButtonBoxServer, 6, 0, 1, 3);
     819                if (m_pButtonBoxServer)
     820                {
     821                    /* Configure button-box: */
     822                    m_pButtonBoxServer->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
     823                    connect(m_pButtonBoxServer, &QIDialogButtonBox::clicked, this, &UIDetailsWidgetHostNetwork::sltHandleButtonBoxClick);
     824
     825                    /* Add into layout: */
     826                    pLayoutDHCPServer->addWidget(m_pButtonBoxServer, 6, 0, 1, 3);
     827                }
    800828            }
    801829        }
     
    809837    /* Toggle IPv4 & IPv6 interface fields availability: */
    810838    const bool fIsInterfaceConfigurable = !m_newData.m_interface.m_fDHCPEnabled;
    811     m_pLabelIPv4->setEnabled(fIsInterfaceConfigurable);
    812     m_pLabelNMv4->setEnabled(fIsInterfaceConfigurable);
    813     m_pEditorIPv4->setEnabled(fIsInterfaceConfigurable);
    814     m_pEditorNMv4->setEnabled(fIsInterfaceConfigurable);
     839    if (m_pLabelIPv4)
     840        m_pLabelIPv4->setEnabled(fIsInterfaceConfigurable);
     841    if (m_pLabelNMv4)
     842        m_pLabelNMv4->setEnabled(fIsInterfaceConfigurable);
     843    if (m_pEditorIPv4)
     844        m_pEditorIPv4->setEnabled(fIsInterfaceConfigurable);
     845    if (m_pEditorNMv4)
     846        m_pEditorNMv4->setEnabled(fIsInterfaceConfigurable);
    815847
    816848    /* Load IPv4 interface fields: */
    817     m_pButtonAutomatic->setChecked(!fIsInterfaceConfigurable);
    818     m_pButtonManual->setChecked(fIsInterfaceConfigurable);
    819     m_pEditorIPv4->setText(m_newData.m_interface.m_strAddress);
    820     m_pEditorNMv4->setText(m_newData.m_interface.m_strMask);
     849    if (m_pButtonAutomatic)
     850        m_pButtonAutomatic->setChecked(!fIsInterfaceConfigurable);
     851    if (m_pButtonManual)
     852        m_pButtonManual->setChecked(fIsInterfaceConfigurable);
     853    if (m_pEditorIPv4)
     854        m_pEditorIPv4->setText(m_newData.m_interface.m_strAddress);
     855    if (m_pEditorNMv4)
     856        m_pEditorNMv4->setText(m_newData.m_interface.m_strMask);
    821857
    822858    /* Toggle IPv6 interface fields availability: */
    823859    const bool fIsIpv6Configurable = fIsInterfaceConfigurable && m_newData.m_interface.m_fSupportedIPv6;
    824     m_pLabelIPv6->setEnabled(fIsIpv6Configurable);
    825     m_pLabelNMv6->setEnabled(fIsIpv6Configurable);
    826     m_pEditorIPv6->setEnabled(fIsIpv6Configurable);
    827     m_pEditorNMv6->setEnabled(fIsIpv6Configurable);
     860    if (m_pLabelIPv6)
     861        m_pLabelIPv6->setEnabled(fIsIpv6Configurable);
     862    if (m_pLabelNMv6)
     863        m_pLabelNMv6->setEnabled(fIsIpv6Configurable);
     864    if (m_pEditorIPv6)
     865        m_pEditorIPv6->setEnabled(fIsIpv6Configurable);
     866    if (m_pEditorNMv6)
     867        m_pEditorNMv6->setEnabled(fIsIpv6Configurable);
    828868
    829869    /* Load IPv6 interface fields: */
    830     m_pEditorIPv6->setText(m_newData.m_interface.m_strAddress6);
    831     m_pEditorNMv6->setText(m_newData.m_interface.m_strPrefixLength6);
     870    if (m_pEditorIPv6)
     871        m_pEditorIPv6->setText(m_newData.m_interface.m_strAddress6);
     872    if (m_pEditorNMv6)
     873        m_pEditorNMv6->setText(m_newData.m_interface.m_strPrefixLength6);
    832874}
    833875
     
    836878    /* Toggle DHCP server fields availability: */
    837879    const bool fIsDHCPServerEnabled = m_newData.m_dhcpserver.m_fEnabled;
    838     m_pLabelDHCPAddress->setEnabled(fIsDHCPServerEnabled);
    839     m_pLabelDHCPMask->setEnabled(fIsDHCPServerEnabled);
    840     m_pLabelDHCPLowerAddress->setEnabled(fIsDHCPServerEnabled);
    841     m_pLabelDHCPUpperAddress->setEnabled(fIsDHCPServerEnabled);
    842     m_pEditorDHCPAddress->setEnabled(fIsDHCPServerEnabled);
    843     m_pEditorDHCPMask->setEnabled(fIsDHCPServerEnabled);
    844     m_pEditorDHCPLowerAddress->setEnabled(fIsDHCPServerEnabled);
    845     m_pEditorDHCPUpperAddress->setEnabled(fIsDHCPServerEnabled);
     880    if (m_pLabelDHCPAddress)
     881        m_pLabelDHCPAddress->setEnabled(fIsDHCPServerEnabled);
     882    if (m_pLabelDHCPMask)
     883        m_pLabelDHCPMask->setEnabled(fIsDHCPServerEnabled);
     884    if (m_pLabelDHCPLowerAddress)
     885        m_pLabelDHCPLowerAddress->setEnabled(fIsDHCPServerEnabled);
     886    if (m_pLabelDHCPUpperAddress)
     887        m_pLabelDHCPUpperAddress->setEnabled(fIsDHCPServerEnabled);
     888    if (m_pEditorDHCPAddress)
     889        m_pEditorDHCPAddress->setEnabled(fIsDHCPServerEnabled);
     890    if (m_pEditorDHCPMask)
     891        m_pEditorDHCPMask->setEnabled(fIsDHCPServerEnabled);
     892    if (m_pEditorDHCPLowerAddress)
     893        m_pEditorDHCPLowerAddress->setEnabled(fIsDHCPServerEnabled);
     894    if (m_pEditorDHCPUpperAddress)
     895        m_pEditorDHCPUpperAddress->setEnabled(fIsDHCPServerEnabled);
    846896
    847897    /* Load DHCP server fields: */
    848     m_pCheckBoxDHCP->setChecked(fIsDHCPServerEnabled);
    849     m_pEditorDHCPAddress->setText(m_newData.m_dhcpserver.m_strAddress);
    850     m_pEditorDHCPMask->setText(m_newData.m_dhcpserver.m_strMask);
    851     m_pEditorDHCPLowerAddress->setText(m_newData.m_dhcpserver.m_strLowerAddress);
    852     m_pEditorDHCPUpperAddress->setText(m_newData.m_dhcpserver.m_strUpperAddress);
     898    if (m_pCheckBoxDHCP)
     899        m_pCheckBoxDHCP->setChecked(fIsDHCPServerEnabled);
     900    if (m_pEditorDHCPAddress)
     901        m_pEditorDHCPAddress->setText(m_newData.m_dhcpserver.m_strAddress);
     902    if (m_pEditorDHCPMask)
     903        m_pEditorDHCPMask->setText(m_newData.m_dhcpserver.m_strMask);
     904    if (m_pEditorDHCPLowerAddress)
     905        m_pEditorDHCPLowerAddress->setText(m_newData.m_dhcpserver.m_strLowerAddress);
     906    if (m_pEditorDHCPUpperAddress)
     907        m_pEditorDHCPUpperAddress->setText(m_newData.m_dhcpserver.m_strUpperAddress);
    853908
    854909    /* Invent default values if server was enabled
    855910     * but at least one current value is invalid: */
    856911    if (   fIsDHCPServerEnabled
     912        && m_pEditorDHCPAddress
     913        && m_pEditorDHCPMask
     914        && m_pEditorDHCPLowerAddress
     915        && m_pEditorDHCPUpperAddress
    857916        && (   m_pEditorDHCPAddress->text().isEmpty()
    858917            || m_pEditorDHCPAddress->text() == "0.0.0.0"
     
    876935{
    877936    /* Validate 'Interface' tab content: */
    878     if (!pWidget || pWidget == m_pErrorPaneAutomatic)
     937    if (m_pErrorPaneAutomatic && (!pWidget || pWidget == m_pErrorPaneAutomatic))
    879938    {
    880939        const bool fError =    m_newData.m_interface.m_fDHCPEnabled
     
    882941        m_pErrorPaneAutomatic->setVisible(fError);
    883942    }
    884     if (!pWidget || pWidget == m_pErrorPaneManual)
     943    if (m_pErrorPaneManual && (!pWidget || pWidget == m_pErrorPaneManual))
    885944    {
    886945        const bool fError = false;
    887946        m_pErrorPaneManual->setVisible(fError);
    888947    }
    889     if (!pWidget || pWidget == m_pErrorPaneIPv4)
     948    if (m_pErrorPaneIPv4 && (!pWidget || pWidget == m_pErrorPaneIPv4))
    890949    {
    891950        const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
     
    895954        m_pErrorPaneIPv4->setVisible(fError);
    896955    }
    897     if (!pWidget || pWidget == m_pErrorPaneNMv4)
     956    if (m_pErrorPaneNMv4 && (!pWidget || pWidget == m_pErrorPaneNMv4))
    898957    {
    899958        const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
     
    903962        m_pErrorPaneNMv4->setVisible(fError);
    904963    }
    905     if (!pWidget || pWidget == m_pErrorPaneIPv6)
     964    if (m_pErrorPaneIPv6 && (!pWidget || pWidget == m_pErrorPaneIPv6))
    906965    {
    907966        const bool fError =    !m_newData.m_interface.m_fDHCPEnabled
     
    912971        m_pErrorPaneIPv6->setVisible(fError);
    913972    }
    914     if (!pWidget || pWidget == m_pErrorPaneNMv6)
     973    if (m_pErrorPaneNMv6 && (!pWidget || pWidget == m_pErrorPaneNMv6))
    915974    {
    916975        bool fIsMaskPrefixLengthNumber = false;
     
    925984
    926985    /* Validate 'DHCP server' tab content: */
    927     if (!pWidget || pWidget == m_pErrorPaneDHCPAddress)
     986    if (m_pErrorPaneDHCPAddress && (!pWidget || pWidget == m_pErrorPaneDHCPAddress))
    928987    {
    929988        const bool fError =    m_newData.m_dhcpserver.m_fEnabled
     
    932991        m_pErrorPaneDHCPAddress->setVisible(fError);
    933992    }
    934     if (!pWidget || pWidget == m_pErrorPaneDHCPMask)
     993    if (m_pErrorPaneDHCPMask && (!pWidget || pWidget == m_pErrorPaneDHCPMask))
    935994    {
    936995        const bool fError =    m_newData.m_dhcpserver.m_fEnabled
     
    939998        m_pErrorPaneDHCPMask->setVisible(fError);
    940999    }
    941     if (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress)
     1000    if (m_pErrorPaneDHCPLowerAddress && (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress))
    9421001    {
    9431002        const bool fError =    m_newData.m_dhcpserver.m_fEnabled
     
    9461005        m_pErrorPaneDHCPLowerAddress->setVisible(fError);
    9471006    }
    948     if (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress)
     1007    if (m_pErrorPaneDHCPUpperAddress && (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress))
    9491008    {
    9501009        const bool fError =    m_newData.m_dhcpserver.m_fEnabled
     
    9611020{
    9621021    /* Translate 'Interface' tab content: */
    963     if (!pWidget || pWidget == m_pErrorPaneAutomatic)
     1022    if (m_pErrorPaneAutomatic && (!pWidget || pWidget == m_pErrorPaneAutomatic))
    9641023        m_pErrorPaneAutomatic->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> is set to obtain the address automatically "
    9651024                                             "but the corresponding DHCP server is not enabled.").arg(m_newData.m_interface.m_strName));
    966     if (!pWidget || pWidget == m_pErrorPaneIPv4)
     1025    if (m_pErrorPaneIPv4 && (!pWidget || pWidget == m_pErrorPaneIPv4))
    9671026        m_pErrorPaneIPv4->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    9681027                                        "IPv4 address.").arg(m_newData.m_interface.m_strName));
    969     if (!pWidget || pWidget == m_pErrorPaneNMv4)
     1028    if (m_pErrorPaneNMv4 && (!pWidget || pWidget == m_pErrorPaneNMv4))
    9701029        m_pErrorPaneNMv4->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    9711030                                        "IPv4 network mask.").arg(m_newData.m_interface.m_strName));
    972     if (!pWidget || pWidget == m_pErrorPaneIPv6)
     1031    if (m_pErrorPaneIPv6 && (!pWidget || pWidget == m_pErrorPaneIPv6))
    9731032        m_pErrorPaneIPv6->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    9741033                                        "IPv6 address.").arg(m_newData.m_interface.m_strName));
    975     if (!pWidget || pWidget == m_pErrorPaneNMv6)
     1034    if (m_pErrorPaneNMv6 && (!pWidget || pWidget == m_pErrorPaneNMv6))
    9761035        m_pErrorPaneNMv6->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    9771036                                        "IPv6 prefix length.").arg(m_newData.m_interface.m_strName));
    9781037
    9791038    /* Translate 'DHCP server' tab content: */
    980     if (!pWidget || pWidget == m_pErrorPaneDHCPAddress)
     1039    if (m_pErrorPaneDHCPAddress && (!pWidget || pWidget == m_pErrorPaneDHCPAddress))
    9811040        m_pErrorPaneDHCPAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    9821041                                               "DHCP server address.").arg(m_newData.m_interface.m_strName));
    983     if (!pWidget || pWidget == m_pErrorPaneDHCPMask)
     1042    if (m_pErrorPaneDHCPMask && (!pWidget || pWidget == m_pErrorPaneDHCPMask))
    9841043        m_pErrorPaneDHCPMask->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    9851044                                            "DHCP server mask.").arg(m_newData.m_interface.m_strName));
    986     if (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress)
     1045    if (m_pErrorPaneDHCPLowerAddress && (!pWidget || pWidget == m_pErrorPaneDHCPLowerAddress))
    9871046        m_pErrorPaneDHCPLowerAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    9881047                                                    "DHCP server lower address bound.").arg(m_newData.m_interface.m_strName));
    989     if (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress)
     1048    if (m_pErrorPaneDHCPUpperAddress && (!pWidget || pWidget == m_pErrorPaneDHCPUpperAddress))
    9901049        m_pErrorPaneDHCPUpperAddress->setToolTip(tr("Host interface <nobr><b>%1</b></nobr> does not currently have a valid "
    9911050                                                    "DHCP server upper address bound.").arg(m_newData.m_interface.m_strName));
     
    10211080    emit sigDataChanged(m_oldData != m_newData);
    10221081}
    1023 
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