Skip to content

Commit 784eb58

Browse files
Const correctness fixes, note there are unaddressed design issues, see below.
The design issue I see is that we set a PlayerContext for the instance but many methods still take a PlayerContext as a param. Most likely these can just use the instance's PlayerContext.
1 parent 3d4cae1 commit 784eb58

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

mythtv/libs/libmythtv/deletemap.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ bool DeleteMap::Redo(void)
5757
return true;
5858
}
5959

60-
QString DeleteMap::GetUndoMessage(void)
60+
QString DeleteMap::GetUndoMessage(void) const
6161
{
6262
return (HasUndo() ? m_undoStack[m_undoStackPointer].message :
6363
QObject::tr("(Nothing to undo)"));
6464
}
6565

66-
QString DeleteMap::GetRedoMessage(void)
66+
QString DeleteMap::GetRedoMessage(void) const
6767
{
6868
return (HasRedo() ? m_undoStack[m_undoStackPointer + 1].message :
6969
QObject::tr("(Nothing to redo)"));
@@ -192,7 +192,7 @@ void DeleteMap::SetFileEditing(PlayerContext *ctx, bool edit)
192192
}
193193

194194
/// Determines whether the file is currently in edit mode.
195-
bool DeleteMap::IsFileEditing(PlayerContext *ctx)
195+
bool DeleteMap::IsFileEditing(const PlayerContext *ctx)
196196
{
197197
bool result = false;
198198
if (ctx)
@@ -205,7 +205,7 @@ bool DeleteMap::IsFileEditing(PlayerContext *ctx)
205205
return result;
206206
}
207207

208-
bool DeleteMap::IsEmpty(void)
208+
bool DeleteMap::IsEmpty(void) const
209209
{
210210
return m_deleteMap.empty();
211211
}
@@ -512,12 +512,12 @@ MarkTypes DeleteMap::Delete(uint64_t frame)
512512
* \brief Returns true if the given frame is deemed to be within a region
513513
* that should be cut.
514514
*/
515-
bool DeleteMap::IsInDelete(uint64_t frame)
515+
bool DeleteMap::IsInDelete(uint64_t frame) const
516516
{
517517
if (m_deleteMap.isEmpty())
518518
return false;
519519

520-
frm_dir_map_t::Iterator it = m_deleteMap.find(frame);
520+
frm_dir_map_t::const_iterator it = m_deleteMap.find(frame);
521521
if (it != m_deleteMap.end())
522522
return true;
523523

@@ -539,23 +539,24 @@ bool DeleteMap::IsInDelete(uint64_t frame)
539539
/**
540540
* \brief Returns true if the given frame is a temporary/placeholder mark
541541
*/
542-
bool DeleteMap::IsTemporaryMark(uint64_t frame)
542+
bool DeleteMap::IsTemporaryMark(uint64_t frame) const
543543
{
544544
if (m_deleteMap.isEmpty())
545545
return false;
546546

547-
frm_dir_map_t::Iterator it = m_deleteMap.find(frame);
547+
frm_dir_map_t::const_iterator it = m_deleteMap.find(frame);
548548
return (it != m_deleteMap.end()) && (MARK_PLACEHOLDER == it.value());
549549
}
550550

551551
/**
552552
* \brief Returns the next or previous mark. If these do not exist, returns
553553
* either zero (the first frame) or total (the last frame).
554554
*/
555-
uint64_t DeleteMap::GetNearestMark(uint64_t frame, uint64_t total, bool right)
555+
uint64_t DeleteMap::GetNearestMark(
556+
uint64_t frame, uint64_t total, bool right) const
556557
{
557558
uint64_t result;
558-
frm_dir_map_t::Iterator it = m_deleteMap.begin();
559+
frm_dir_map_t::const_iterator it = m_deleteMap.begin();
559560
if (right)
560561
{
561562
result = total;
@@ -579,11 +580,11 @@ uint64_t DeleteMap::GetNearestMark(uint64_t frame, uint64_t total, bool right)
579580
/**
580581
* \brief Returns true if a temporary placeholder mark is defined.
581582
*/
582-
bool DeleteMap::HasTemporaryMark(void)
583+
bool DeleteMap::HasTemporaryMark(void) const
583584
{
584585
if (!m_deleteMap.isEmpty())
585586
{
586-
frm_dir_map_t::Iterator it = m_deleteMap.begin();
587+
frm_dir_map_t::const_iterator it = m_deleteMap.begin();
587588
for ( ; it != m_deleteMap.end(); ++it)
588589
if (MARK_PLACEHOLDER == it.value())
589590
return true;
@@ -667,7 +668,8 @@ void DeleteMap::LoadCommBreakMap(uint64_t total, frm_dir_map_t &map)
667668
}
668669

669670
/// Loads the delete map from the database.
670-
void DeleteMap::LoadMap(uint64_t total, PlayerContext *ctx, QString undoMessage)
671+
void DeleteMap::LoadMap(
672+
uint64_t total, const PlayerContext *ctx, QString undoMessage)
671673
{
672674
if (!ctx || !ctx->playingInfo || gCoreContext->IsDatabaseIgnored())
673675
return;
@@ -683,7 +685,7 @@ void DeleteMap::LoadMap(uint64_t total, PlayerContext *ctx, QString undoMessage)
683685

684686
/// Returns true if an auto-save map was loaded.
685687
/// Does nothing and returns false if not.
686-
bool DeleteMap::LoadAutoSaveMap(uint64_t total, PlayerContext *ctx)
688+
bool DeleteMap::LoadAutoSaveMap(uint64_t total, const PlayerContext *ctx)
687689
{
688690
if (!ctx || !ctx->playingInfo || gCoreContext->IsDatabaseIgnored())
689691
return false;
@@ -780,13 +782,13 @@ bool DeleteMap::TrackerWantsToJump(uint64_t frame, uint64_t total, uint64_t &to)
780782
* \brief Returns the number of the last frame in the video that is not in a
781783
* cut sequence.
782784
*/
783-
uint64_t DeleteMap::GetLastFrame(uint64_t total)
785+
uint64_t DeleteMap::GetLastFrame(uint64_t total) const
784786
{
785787
uint64_t result = total;
786788
if (IsEmpty())
787789
return result;
788790

789-
frm_dir_map_t::Iterator it = m_deleteMap.end();
791+
frm_dir_map_t::const_iterator it = m_deleteMap.end();
790792
--it;
791793

792794
if (it.value() == MARK_CUT_START)
@@ -797,7 +799,7 @@ uint64_t DeleteMap::GetLastFrame(uint64_t total)
797799
/**
798800
* \brief Compares the current cut list with the saved cut list
799801
*/
800-
bool DeleteMap::IsSaved(PlayerContext *ctx)
802+
bool DeleteMap::IsSaved(const PlayerContext *ctx) const
801803
{
802804
if (!ctx || !ctx->playingInfo || gCoreContext->IsDatabaseIgnored())
803805
return true;

mythtv/libs/libmythtv/deletemap.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,26 @@ class DeleteMap
2424
void SetPlayerContext(PlayerContext *ctx) { m_ctx = ctx; }
2525
bool HandleAction(QString &action, uint64_t frame, uint64_t played,
2626
uint64_t total, double rate);
27-
int GetSeekAmount(void) { return m_seekamount; }
27+
int GetSeekAmount(void) const { return m_seekamount; }
2828
void UpdateSeekAmount(int change, double framerate);
2929
void SetSeekAmount(int amount) { m_seekamount = amount; }
3030

3131
void UpdateOSD(uint64_t frame, uint64_t total, double frame_rate,
3232
PlayerContext *ctx, OSD *osd);
3333

34-
bool IsEditing(void) { return m_editing; }
34+
bool IsEditing(void) const { return m_editing; }
3535
void SetEditing(bool edit, OSD *osd = NULL);
3636
void SetFileEditing(PlayerContext *ctx, bool edit);
37-
bool IsFileEditing(PlayerContext *ctx);
38-
bool IsEmpty(void);
39-
bool IsSaved(PlayerContext *ctx);
37+
static bool IsFileEditing(const PlayerContext *ctx);
38+
bool IsEmpty(void) const;
39+
bool IsSaved(const PlayerContext *ctx) const;
4040

4141
void SetMap(const frm_dir_map_t &map);
4242
void LoadCommBreakMap(uint64_t total, frm_dir_map_t &map);
4343
void SaveMap(uint64_t total, PlayerContext *ctx, bool isAutoSave = false);
44-
void LoadMap(uint64_t total, PlayerContext *ctx, QString undoMessage = "");
45-
bool LoadAutoSaveMap(uint64_t total, PlayerContext *ctx);
44+
void LoadMap(uint64_t total, const PlayerContext *ctx,
45+
QString undoMessage = "");
46+
bool LoadAutoSaveMap(uint64_t total, const PlayerContext *ctx);
4647
void CleanMap(uint64_t total);
4748

4849
void Clear(QString undoMessage = "");
@@ -54,21 +55,22 @@ class DeleteMap
5455
void MoveRelative(uint64_t frame, uint64_t total, bool right);
5556
void Move(uint64_t frame, uint64_t to, uint64_t total);
5657

57-
bool IsInDelete(uint64_t frame);
58-
uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right);
59-
bool IsTemporaryMark(uint64_t frame);
60-
bool HasTemporaryMark(void);
61-
uint64_t GetLastFrame(uint64_t total);
58+
bool IsInDelete(uint64_t frame) const;
59+
uint64_t GetNearestMark(uint64_t frame, uint64_t total, bool right) const;
60+
bool IsTemporaryMark(uint64_t frame) const;
61+
bool HasTemporaryMark(void) const;
62+
uint64_t GetLastFrame(uint64_t total) const;
6263

6364
void TrackerReset(uint64_t frame, uint64_t total);
6465
bool TrackerWantsToJump(uint64_t frame, uint64_t total, uint64_t &to);
6566

6667
bool Undo(void);
6768
bool Redo(void);
68-
bool HasUndo(void) { return m_undoStackPointer > 0; }
69-
bool HasRedo(void) { return m_undoStackPointer < m_undoStack.size() - 1; }
70-
QString GetUndoMessage(void);
71-
QString GetRedoMessage(void);
69+
bool HasUndo(void) const { return m_undoStackPointer > 0; }
70+
bool HasRedo(void) const
71+
{ return m_undoStackPointer < m_undoStack.size() - 1; }
72+
QString GetUndoMessage(void) const;
73+
QString GetRedoMessage(void) const;
7274

7375
private:
7476
void Add(uint64_t frame, MarkTypes type);

0 commit comments

Comments
 (0)