VirtualBox

Ignore:
Timestamp:
Mar 24, 2015 5:58:35 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: Machine settings Serializer: Cleanup rework to prepare to the encryption settings integration (step 8): No need for serialize process singleton; Fixing event-loop sync regression from r99174.

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

Legend:

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

    r54928 r54932  
    6565    , m_fPolished(false)
    6666    /* Loading/saving stuff: */
     67    , m_pSerializeProcess(0)
     68    , m_pSerializeProgress(0)
    6769    , m_fLoaded(false)
    6870    , m_fSaved(false)
     
    150152UISettingsDialog::~UISettingsDialog()
    151153{
    152     /* Delete serializer early if exists: */
    153     if (UISettingsSerializer::instance())
    154         delete UISettingsSerializer::instance();
     154    /* Delete serializer if exists: */
     155    if (serializeProcess())
     156    {
     157        delete m_pSerializeProcess;
     158        m_pSerializeProcess = 0;
     159    }
     160    if (serializeProgress())
     161    {
     162        delete m_pSerializeProgress;
     163        m_pSerializeProgress = 0;
     164    }
    155165
    156166    /* Recall popup-pane if any: */
     
    208218void UISettingsDialog::sltMarkLoaded()
    209219{
    210     /* Delete serializer early if exists: */
    211     if (UISettingsSerializer::instance())
    212         delete UISettingsSerializer::instance();
     220    /* Delete serializer if exists: */
     221    if (serializeProcess())
     222    {
     223        delete m_pSerializeProcess;
     224        m_pSerializeProcess = 0;
     225    }
     226    if (serializeProgress())
     227    {
     228        delete m_pSerializeProgress;
     229        m_pSerializeProgress = 0;
     230    }
    213231
    214232    /* Mark as loaded: */
     
    218236void UISettingsDialog::sltMarkSaved()
    219237{
    220     /* Delete serializer early if exists: */
    221     if (UISettingsSerializer::instance())
    222         delete UISettingsSerializer::instance();
     238    /* Delete serializer if exists: */
     239    if (serializeProcess())
     240    {
     241        delete m_pSerializeProcess;
     242        m_pSerializeProcess = 0;
     243    }
     244    if (serializeProgress())
     245    {
     246        delete m_pSerializeProgress;
     247        m_pSerializeProgress = 0;
     248    }
    223249
    224250    /* Mark as saved: */
     
    250276
    251277    /* Create settings loader: */
    252     UISettingsSerializer *pSettingsLoader = new UISettingsSerializer(this, UISettingsSerializer::Load,
    253                                                                      data, m_pSelector->settingPages());
    254     AssertPtrReturnVoid(pSettingsLoader);
     278    m_pSerializeProcess = new UISettingsSerializer(this, UISettingsSerializer::Load,
     279                                                   data, m_pSelector->settingPages());
     280    AssertPtrReturnVoid(m_pSerializeProcess);
    255281    {
    256282        /* Configure settings loader: */
    257         connect(pSettingsLoader, SIGNAL(sigNotifyAboutProcessStarted()), this, SLOT(sltHandleProcessStarted()));
    258         connect(pSettingsLoader, SIGNAL(sigNotifyAboutPagePostprocessed(int)), this, SLOT(sltHandlePageProcessed()));
    259         connect(pSettingsLoader, SIGNAL(sigNotifyAboutProcessFinished()), this, SLOT(sltMarkLoaded()));
     283        connect(m_pSerializeProcess, SIGNAL(sigNotifyAboutProcessStarted()), this, SLOT(sltHandleProcessStarted()));
     284        connect(m_pSerializeProcess, SIGNAL(sigNotifyAboutPagePostprocessed(int)), this, SLOT(sltHandlePageProcessed()));
     285        connect(m_pSerializeProcess, SIGNAL(sigNotifyAboutProcessFinished()), this, SLOT(sltMarkLoaded()));
    260286        /* Raise current page priority: */
    261         pSettingsLoader->raisePriorityOfPage(m_pSelector->currentId());
     287        m_pSerializeProcess->raisePriorityOfPage(m_pSelector->currentId());
    262288        /* Start settings loader: */
    263         pSettingsLoader->start();
     289        m_pSerializeProcess->start();
    264290    }
    265291
    266292    /* Upload data finally: */
    267     data = pSettingsLoader->data();
     293    data = m_pSerializeProcess->data();
    268294}
    269295
     
    274300
    275301    /* Create settings saver: */
    276     UISettingsSerializerProgress *pSettingsSaveProgress = new UISettingsSerializerProgress(this, UISettingsSerializer::Save,
    277                                                                                            data, m_pSelector->settingPages());
    278     AssertPtrReturnVoid(pSettingsSaveProgress);
    279     {
    280         /* Configure settings saver: */
    281         connect(pSettingsSaveProgress, SIGNAL(finished(int)), this, SLOT(sltMarkSaved()));
     302    m_pSerializeProgress = new UISettingsSerializerProgress(this, UISettingsSerializer::Save,
     303                                                            data, m_pSelector->settingPages());
     304    AssertPtrReturnVoid(m_pSerializeProgress);
     305    {
    282306        /* Start settings saver: */
    283         pSettingsSaveProgress->exec();
     307        m_pSerializeProgress->exec();
    284308    }
    285309
    286310    /* Upload data finally: */
    287     data = pSettingsSaveProgress->data();
     311    data = m_pSerializeProgress->data();
    288312}
    289313
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h

    r54928 r54932  
    3232class VBoxSettingsSelector;
    3333class UISettingsPage;
     34class UISettingsSerializer;
     35class UISettingsSerializerProgress;
    3436
    3537/* Using declarations: */
     
    6870
    6971protected:
     72
     73    /** Returns the serialize process instance. */
     74    UISettingsSerializer* serializeProcess() const { return m_pSerializeProcess; }
     75    /** Returns the serialize progress instance. */
     76    UISettingsSerializerProgress* serializeProgress() const { return m_pSerializeProgress; }
    7077
    7178    /** Loads the @a data. */
     
    136143    bool m_fPolished;
    137144
     145    /** Holds the serialize process instance. */
     146    UISettingsSerializer *m_pSerializeProcess;
     147    /** Holds the serialize progress instance. */
     148    UISettingsSerializerProgress *m_pSerializeProgress;
     149
    138150    /* Loading/saving stuff: */
    139151    bool m_fLoaded;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialogSpecific.cpp

    r54928 r54932  
    235235    else if (!(newSettings == settings))
    236236        vboxGlobal().setSettings(newSettings);
     237
     238    /* Mark as saved: */
     239    sltMarkSaved();
    237240}
    238241
     
    573576    if (!m_machine.isOk())
    574577        msgCenter().cannotSaveMachineSettings(m_machine, this);
     578
     579    /* Mark as saved: */
     580    sltMarkSaved();
    575581}
    576582
     
    780786void UISettingsDialogMachine::sltCategoryChanged(int cId)
    781787{
    782     if (UISettingsSerializer::instance())
    783         UISettingsSerializer::instance()->raisePriorityOfPage(cId);
     788    if (serializeProcess())
     789        serializeProcess()->raisePriorityOfPage(cId);
    784790
    785791    UISettingsDialog::sltCategoryChanged(cId);
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.cpp

    r54928 r54932  
    2626#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    2727
    28 UISettingsSerializer* UISettingsSerializer::m_spInstance = 0;
    29 
    3028UISettingsSerializer::UISettingsSerializer(QObject *pParent, SerializationDirection direction,
    3129                                           const QVariant &data, const UISettingsPageList &pages)
     
    3634    , m_iIdOfHighPriorityPage(-1)
    3735{
    38     /* Prepare instance: */
    39     m_spInstance = this;
    40 
    4136    /* Copy the page(s) from incoming list to our map: */
    4237    foreach (UISettingsPage *pPage, pages)
     
    5853    if (isRunning())
    5954        wait();
    60 
    61     /* Cleanup instance: */
    62     m_spInstance = 0;
    6355}
    6456
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsSerializer.h

    r54928 r54932  
    6666    enum SerializationDirection { Load, Save };
    6767
    68     /** Returns the singleton instance. */
    69     static UISettingsSerializer* instance() { return m_spInstance; }
    70 
    7168    /** Constructor.
    7269      * @param pParent   being passed to the base-class,
     
    109106    /** Worker-thread serialization rutine. */
    110107    void run();
    111 
    112     /** Holds the singleton instance. */
    113     static UISettingsSerializer *m_spInstance;
    114108
    115109    /** Holds the load/save direction. */
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