Changeset View
Changeset View
Standalone View
Standalone View
src/GlobalCurrentTrackActions.cpp
Show All 30 Lines | 27 | { | |||
---|---|---|---|---|---|
31 | return s_GlobalCurrentTrackActions_instance; | 31 | return s_GlobalCurrentTrackActions_instance; | ||
32 | } | 32 | } | ||
33 | } | 33 | } | ||
34 | 34 | | |||
35 | 35 | | |||
36 | GlobalCurrentTrackActions::GlobalCurrentTrackActions() | 36 | GlobalCurrentTrackActions::GlobalCurrentTrackActions() | ||
37 | {} | 37 | {} | ||
38 | 38 | | |||
39 | | ||||
40 | GlobalCurrentTrackActions::~GlobalCurrentTrackActions() | 39 | GlobalCurrentTrackActions::~GlobalCurrentTrackActions() | ||
41 | {} | 40 | {} | ||
42 | 41 | | |||
43 | void GlobalCurrentTrackActions::addAction( QAction * action ) | 42 | void GlobalCurrentTrackActions::addAction( QAction * action ) | ||
44 | { | 43 | { | ||
45 | m_actions.append( action ); | 44 | m_actions.append( action ); | ||
45 | QObject::connect( action, &QObject::destroyed, this, [this, action]() { m_actions.removeAll( action ); } ); | ||||
46 | } | 46 | } | ||
47 | 47 | | |||
48 | QList< QAction * > GlobalCurrentTrackActions::actions() | 48 | QList< QAction * > GlobalCurrentTrackActions::actions() | ||
49 | { | 49 | { | ||
50 | // Here we filter out dangling pointers to already destroyed QActions | 50 | return m_actions; | ||
51 | | ||||
52 | QList<QAction*> validActions; | | |||
53 | | ||||
54 | foreach( QAction* action, m_actions ) | | |||
55 | validActions.append( action ); | | |||
56 | | ||||
57 | return validActions; | | |||
58 | } | 51 | } | ||
59 | 52 | | |||
60 | 53 | |