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

antonvw / wex / 15349103000

30 May 2025 02:33PM UTC coverage: 28.052% (-30.9%) from 58.951%
15349103000

push

github

antonvw
fixing the segfault

7896 of 31160 branches covered (25.34%)

Branch coverage included in aggregate %.

6430 of 19909 relevant lines covered (32.3%)

64.4 hits per line

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

63.73
/src/core/function-repeat.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
// Name:      function-repeat.cpp
3
// Purpose:   Implementation of class wex::function_repeat
4
// Author:    Anton van Wezenbeek
5
// Copyright: (c) 2023-2024 Anton van Wezenbeek
6
////////////////////////////////////////////////////////////////////////////////
7

8
#include <wex/core/config.h>
9
#include <wex/core/function-repeat.h>
10
#include <wex/core/log.h>
11
#include <wx/window.h>
12

13
#include <utility>
14

15
/// Supported actions.
16
enum class wex::function_repeat::action_t
17
{
18
  START, ///< starts the action
19
  STOP   ///< stops the action
20
};
21

22
wex::function_repeat::function_repeat(
7✔
23
  const std::string& name,
24
  wxEvtHandler*      evt,
25
  repeat_t           f)
7✔
26
  : m_name(name)
7✔
27
  , m_handler(evt)
7✔
28
  , m_f(std::move(f))
7✔
29
  , m_reflect(
28!
30
      {REFLECT_ADD("id", m_timer_id),
12✔
31
       REFLECT_ADD("interval", m_timer->GetInterval())})
19✔
32
{
33
}
21!
34

35
wex::function_repeat::~function_repeat()
×
36
{
37
  delete m_timer; // stops timer if running
×
38
}
×
39

40
bool wex::function_repeat::action(action_t a)
6✔
41
{
42
  switch (a)
6!
43
  {
44
    case action_t::START:
5✔
45
      if (
5✔
46
        !config("AllowSync").get(true) ||
20!
47
        (m_timer != nullptr && m_timer->IsRunning()))
5!
48
      {
49
        return false;
×
50
      }
51

52
      m_timer_id = wxWindowBase::NewControlId();
5✔
53
      m_timer    = new wxTimer(m_handler, m_timer_id);
5!
54

55
      if (!m_timer->Start(config("Repeater").get(1000)))
15!
56
      {
57
        return false;
×
58
      }
59

60
      log::trace("repeat " + m_name) << m_reflect.log();
5✔
61

62
      m_handler->Bind(wxEVT_TIMER, m_f, m_timer_id);
5✔
63
      break;
5✔
64

65
    case action_t::STOP:
1✔
66
      if (m_timer == nullptr || !m_timer->IsRunning())
1!
67
      {
68
        return false;
×
69
      }
70

71
      m_timer->Stop();
1✔
72
      m_handler->Unbind(wxEVT_TIMER, m_f, m_timer_id);
1✔
73
      break;
1✔
74
  }
75

76
  return true;
6✔
77
}
78

79
bool wex::function_repeat::activate(bool start)
6✔
80
{
81
  return action(start ? action_t::START : action_t::STOP);
6✔
82
}
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