void UISettingsSerializer::run()
{
    /* Initialize COM for other thread: */
    COMBase::InitializeCOM(false);

    /* Mark all the pages initially as NOT processed: */
    foreach (UISettingsPage *pPage, m_pages.values())
        pPage->setProcessed(false);

    /* Iterate over the all left settings pages: */
    UISettingsPageMap pages(m_pages);
    while (!pages.empty())
    {
        /* Get required page pointer, protect map by mutex while getting pointer: */
        UISettingsPage *pPage = m_iIdOfHighPriorityPage != -1 && pages.contains(m_iIdOfHighPriorityPage) ?
                                pages.value(m_iIdOfHighPriorityPage) : *pages.begin();
        /* Reset request of high priority: */
        if (m_iIdOfHighPriorityPage != -1)
            m_iIdOfHighPriorityPage = -1;
        /* Process this page if its enabled: */
        connect(pPage, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)),
                this, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)));
        connect(pPage, SIGNAL(sigOperationProgressError(QString)),
                this, SIGNAL(sigOperationProgressError(QString)));
        if (pPage->isEnabled())
        {
            if (m_enmDirection == Load)
                pPage->loadToCacheFrom(m_data);
            if (m_enmDirection == Save)
                pPage->saveFromCacheTo(m_data);
        }
        /* Remember what page was processed: */
        disconnect(pPage, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)),
                   this, SIGNAL(sigOperationProgressChange(ulong, QString, ulong, ulong)));
        disconnect(pPage, SIGNAL(sigOperationProgressError(QString)),
                   this, SIGNAL(sigOperationProgressError(QString)));
        pPage->setProcessed(true);
        /* Remove processed page from our map: */
        pages.remove(pPage->id());
        /* Notify listeners about page was processed: */
        emit sigNotifyAboutPageProcessed(pPage->id());
        /* If serializer saves settings => wake up GUI thread: */
        if (m_enmDirection == Save)
            m_condition.wakeAll();
        /* Break further processing if page had failed: */
        if (pPage->failed())
            break;
    }
    /* Notify listeners about all pages were processed: */
    emit sigNotifyAboutPagesProcessed();
    /* If serializer saves settings => wake up GUI thread: */
    if (m_enmDirection == Save)
        m_condition.wakeAll();

    /* Deinitialize COM for other thread: */
    COMBase::CleanupCOM();
}
 /* Set pages list: */
 void setPageList(const UISettingsPageList &pageList)
 {
     for (int iPageIndex = 0; iPageIndex < pageList.size(); ++iPageIndex)
     {
         UISettingsPage *pPage = pageList[iPageIndex];
         m_pages.insert(pPage->id(), pPage);
     }
 }