VirtualBox

Ignore:
Timestamp:
Mar 24, 2015 3:08:36 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings Serializer: Cleanup rework to prepare to the encryption settings integration (step 6): Manual serializer destruction.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/settings
Files:
3 edited

Legend:

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

    r54922 r54923  
    203203void UISettingsDialog::sltMarkLoaded()
    204204{
     205    /* Delete serializer early if exists: */
     206    if (UISettingsSerializer::instance())
     207        delete UISettingsSerializer::instance();
     208
    205209    /* Mark as loaded: */
    206210    m_fLoaded = true;
     
    209213void UISettingsDialog::sltMarkSaved()
    210214{
     215    /* Delete serializer early if exists: */
     216    if (UISettingsSerializer::instance())
     217        delete UISettingsSerializer::instance();
     218
    211219    /* Mark as saved: */
    212220    m_fSaved = true;
     
    241249                                                                     QVariant::fromValue(data),
    242250                                                                     m_pSelector->settingPages());
    243     connect(pSettingsLoader, SIGNAL(destroyed(QObject*)), this, SLOT(sltMarkLoaded()));
    244     /* Ask to raise required page priority: */
    245     pSettingsLoader->raisePriorityOfPage(m_pSelector->currentId());
    246     /* Start loader: */
    247     pSettingsLoader->start();
     251    AssertPtrReturnVoid(pSettingsLoader);
     252    {
     253        /* Configure settings loader: */
     254        connect(pSettingsLoader, SIGNAL(sigNotifyAboutProcessStarted()), this, SLOT(sltHandleProcessStarted()));
     255        connect(pSettingsLoader, SIGNAL(sigNotifyAboutPagePostprocessed(int)), this, SLOT(sltHandlePageProcessed()));
     256        connect(pSettingsLoader, SIGNAL(sigNotifyAboutProcessFinished()), this, SLOT(sltMarkLoaded()));
     257        /* Raise current page priority: */
     258        pSettingsLoader->raisePriorityOfPage(m_pSelector->currentId());
     259        /* Start settings loader: */
     260        pSettingsLoader->start();
     261    }
    248262
    249263    /* Upload data finally: */
     
    261275                                                                    QVariant::fromValue(data),
    262276                                                                    m_pSelector->settingPages());
    263     /* Start saver: */
    264     pSettingsSaver->start();
     277    AssertPtrReturnVoid(pSettingsSaver);
     278    {
     279        /* Start settings saver: */
     280        pSettingsSaver->start();
     281    }
    265282
    266283    /* Upload data finally: */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.cpp

    r54886 r54923  
    3434    , m_data(data)
    3535    , m_fSavingComplete(m_direction == Load)
    36     , m_fAllowToDestroySerializer(m_direction == Load)
    3736    , m_iIdOfHighPriorityPage(-1)
    3837{
     
    4746    }
    4847
    49     /* Connecting this signals: */
     48    /* Handling internal signals, they are also redirected in their handlers: */
    5049    connect(this, SIGNAL(sigNotifyAboutPageProcessed(int)), this, SLOT(sltHandleProcessedPage(int)), Qt::QueuedConnection);
    5150    connect(this, SIGNAL(sigNotifyAboutPagesProcessed()), this, SLOT(sltHandleProcessedPages()), Qt::QueuedConnection);
    52     connect(this, SIGNAL(finished()), this, SLOT(sltDestroySerializer()), Qt::QueuedConnection);
    53     /* Connecting parent signals: */
    54     connect(this, SIGNAL(sigNotifyAboutProcessStarted()), parent(), SLOT(sltHandleProcessStarted()), Qt::QueuedConnection);
    55     connect(this, SIGNAL(sigNotifyAboutPageProcessed(int)), parent(), SLOT(sltHandlePageProcessed()), Qt::QueuedConnection);
     51
     52    /* Redirecting unhandled internal signals: */
     53    connect(this, SIGNAL(finished()), this, SIGNAL(sigNotifyAboutProcessFinished()), Qt::QueuedConnection);
    5654}
    5755
     
    108106            m_mutex.unlock();
    109107        }
    110         /* Allow to destroy serializer finally: */
    111         m_fAllowToDestroySerializer = true;
    112108    }
    113109}
     
    128124        }
    129125    }
     126    /* Notify listeners about page postprocessed: */
     127    emit sigNotifyAboutPagePostprocessed(iPageId);
    130128}
    131129
     
    146144            pPage->revalidate();
    147145    }
    148 }
    149 
    150 void UISettingsSerializer::sltDestroySerializer()
    151 {
    152     /* If not yet all events were processed,
    153      * we should postpone destruction for now: */
    154     if (!m_fAllowToDestroySerializer)
    155         QTimer::singleShot(0, this, SLOT(sltDestroySerializer()));
    156     else
    157         deleteLater();
     146    /* Notify listeners about pages postprocessed: */
     147    emit sigNotifyAboutPagesPostprocessed();
    158148}
    159149
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.h

    r54886 r54923  
    4646    /** Notifies GUI thread about some page was processed. */
    4747    void sigNotifyAboutPageProcessed(int iPageId);
    48 
    4948    /** Notifies GUI thread about all pages were processed. */
    5049    void sigNotifyAboutPagesProcessed();
     50
     51    /** Notifies listeners about some page was post-processed. */
     52    void sigNotifyAboutPagePostprocessed(int iPageId);
     53    /** Notifies listeners about all pages were post-processed. */
     54    void sigNotifyAboutPagesPostprocessed();
     55
     56    /** Notifies listeners about process has been finished. */
     57    void sigNotifyAboutProcessFinished();
    5158
    5259public:
     
    8895    void sltHandleProcessedPages();
    8996
    90     /** Killing serializer, softly :) */
    91     void sltDestroySerializer();
    92 
    9397protected:
    9498
     
    109113    /** Holds whether the save was complete. */
    110114    bool m_fSavingComplete;
    111     /** Holds whether it is allowed to destroy the serializer. */
    112     bool m_fAllowToDestroySerializer;
    113115    /** Holds the ID of the high priority page. */
    114116    int m_iIdOfHighPriorityPage;
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