VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/objects/UIExecutionQueue.cpp

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1/* $Id: UIExecutionQueue.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIExecutionQueue class implementation.
4 */
5
6/*
7 * Copyright (C) 2021-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* GUI includes: */
29#include "UIExecutionQueue.h"
30
31
32/*********************************************************************************************************************************
33* Class UIExecutionStep implementation. *
34*********************************************************************************************************************************/
35
36UIExecutionStep::UIExecutionStep()
37{
38}
39
40
41/*********************************************************************************************************************************
42* Class UIExecutionQueue implementation. *
43*********************************************************************************************************************************/
44
45UIExecutionQueue::UIExecutionQueue(QObject *pParent /* = 0 */)
46 : QObject(pParent)
47 , m_pExecutedStep(0)
48{
49 /* Listen for the queue start signal: */
50 connect(this, &UIExecutionQueue::sigStartQueue,
51 this, &UIExecutionQueue::sltStartsSubsequentStep,
52 Qt::QueuedConnection);
53}
54
55UIExecutionQueue::~UIExecutionQueue()
56{
57 /* Cleanup current step: */
58 delete m_pExecutedStep;
59 m_pExecutedStep = 0;
60
61 /* Dequeue steps one-by-one: */
62 while (!m_queue.isEmpty())
63 delete m_queue.dequeue();
64}
65
66void UIExecutionQueue::enqueue(UIExecutionStep *pUpdateStep)
67{
68 m_queue.enqueue(pUpdateStep);
69}
70
71void UIExecutionQueue::sltStartsSubsequentStep()
72{
73 /* Cleanup current step: */
74 delete m_pExecutedStep;
75 m_pExecutedStep = 0;
76
77 /* If queue is empty, we are finished: */
78 if (m_queue.isEmpty())
79 emit sigQueueFinished();
80 else
81 {
82 /* Otherwise dequeue first step and start it: */
83 m_pExecutedStep = m_queue.dequeue();
84 connect(m_pExecutedStep, &UIExecutionStep::sigStepFinished,
85 this, &UIExecutionQueue::sltStartsSubsequentStep,
86 Qt::QueuedConnection);
87 m_pExecutedStep->exec();
88 }
89}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use