• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IJHack / QtPass / 24751335583

21 Apr 2026 11:14PM UTC coverage: 27.394%. First build
24751335583

Pull #1129

github

web-flow
Merge cbeb763fb into ddeb57b55
Pull Request #1129: Fix: QProgressIndicator memory leak and dark mode support

1 of 10 new or added lines in 2 files covered. (10.0%)

1599 of 5837 relevant lines covered (27.39%)

30.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.56
/src/qprogressindicator.cpp
1
// SPDX-FileCopyrightText: 2011 Morgan Leborgne
2
// SPDX-FileCopyrightText: 2015 Anne Jan Brouwer
3
// SPDX-License-Identifier: MIT
4
#include "qprogressindicator.h"
5
#include <QPainter>
6

7
/**
8
 * @brief QProgressIndicator::QProgressIndicator constructor.
9
 * @param parent widget the indicator is placed in.
10
 */
11
QProgressIndicator::QProgressIndicator(QWidget *parent)
16✔
12
    : QWidget(parent), m_angle(0), m_timerId(-1), m_delay(40),
16✔
13
      m_displayedWhenStopped(false), m_color() {
16✔
14
  setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
16✔
15
  setFocusPolicy(Qt::NoFocus);
16✔
16
}
16✔
17

18
auto QProgressIndicator::isAnimated() const -> bool { return m_timerId != -1; }
17✔
19

20
void QProgressIndicator::setDisplayedWhenStopped(bool state) {
2✔
21
  m_displayedWhenStopped = state;
2✔
22

23
  update();
2✔
24
}
2✔
25

26
auto QProgressIndicator::isDisplayedWhenStopped() const -> bool {
4✔
27
  return m_displayedWhenStopped;
4✔
28
}
29

30
void QProgressIndicator::startAnimation() {
7✔
31
  m_angle = 0;
7✔
32

33
  if (m_timerId == -1) {
7✔
34
    m_timerId = startTimer(m_delay);
6✔
35
  }
36
}
7✔
37

38
void QProgressIndicator::stopAnimation() {
7✔
39
  if (m_timerId != -1) {
7✔
40
    killTimer(m_timerId);
6✔
41
  }
42

43
  m_timerId = -1;
7✔
44

45
  update();
7✔
46
}
7✔
47

48
void QProgressIndicator::setAnimationDelay(int delay) {
1✔
49
  if (m_timerId != -1) {
1✔
50
    killTimer(m_timerId);
×
51
  }
52

53
  m_delay = delay;
1✔
54

55
  if (m_timerId != -1) {
1✔
56
    m_timerId = startTimer(m_delay);
×
57
  }
58
}
1✔
59

60
void QProgressIndicator::setColor(const QColor &color) {
2✔
61
  m_color = color;
2✔
62

63
  update();
2✔
64
}
2✔
65

66
/**
67
 * @brief QProgressIndicator::sizeHint default minimum size.
68
 * @return QSize(20, 20)
69
 */
70
auto QProgressIndicator::sizeHint() const -> QSize { return {20, 20}; }
1✔
71

72
/**
73
 * @brief QProgressIndicator::heightForWidth square ratio.
74
 * @param w requested width
75
 * @return w returned height
76
 */
77
auto QProgressIndicator::heightForWidth(int w) const -> int { return w; }
3✔
78

79
/**
80
 * @brief QProgressIndicator::timerEvent do the actual animation.
81
 */
82
void QProgressIndicator::timerEvent(QTimerEvent * /*event*/) {
×
83
  m_angle = (m_angle + 30) % 360;
×
84

85
  update();
×
86
}
×
87

88
/**
89
 * @brief QProgressIndicator::paintEvent draw the spinner.
90
 */
91
void QProgressIndicator::paintEvent(QPaintEvent * /*event*/) {
×
92
  if (!m_displayedWhenStopped && !isAnimated()) {
×
93
    return;
×
94
  }
95

96
  int width = qMin(this->width(), this->height());
×
97

98
  QPainter p(this);
×
99
  p.setRenderHint(QPainter::Antialiasing);
×
100

101
  auto outerRadius = int((width - 1) * 0.5);
×
102
  auto innerRadius = int((width - 1) * 0.5 * 0.38);
×
103

104
  int capsuleHeight = outerRadius - innerRadius;
×
105
  int capsuleWidth =
106
      (width > 32) ? int(capsuleHeight * 0.23) : int(capsuleHeight * 0.35);
×
107
  int capsuleRadius = capsuleWidth / 2;
×
108

109
  for (int i = 0; i < 12; ++i) {
×
NEW
110
    QColor color = m_color.isValid() ? m_color : palette().windowText().color();
×
NEW
111
    color.setAlphaF(1.0f - (i / 12.0f));
×
112
    p.setPen(Qt::NoPen);
×
113
    p.setBrush(color);
×
114
    p.save();
×
115
    p.translate(rect().center());
×
116
    p.rotate(int(m_angle - i * 30.0f));
×
117
    p.drawRoundedRect(int(-capsuleWidth * 0.5), -(innerRadius + capsuleHeight),
×
118
                      capsuleWidth, capsuleHeight, capsuleRadius,
119
                      capsuleRadius);
120
    p.restore();
×
121
  }
122
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc