Browse files

Convert the use of player_ctx in mythtranscode to QPointer<>

We have far too many places in the transcode code path that delete player_ctx
and return.  Unfortunately, freeing "transcode" also will try to delee
player_ctx, but it's already deleted, and not nulled out.  Rather than putting
many instances of "player_ctx = NULL", I opted to make PlayerContext a
QObject, and then just use QPointer<PlayerContext> as this will clear itself
to NULL as soon as it is destroyed.

Fixes #10616
  • Loading branch information...
1 parent 9839dd7 commit c5a9262355a51b2d2b0465234d79b527c3907e84 @Beirdo Beirdo committed Apr 18, 2012
Showing with 6 additions and 3 deletions.
  1. +3 −1 mythtv/libs/libmythtv/playercontext.h
  2. +3 −2 mythtv/programs/mythtranscode/transcode.h
@@ -11,6 +11,7 @@ using namespace std;
#include <QMutex>
#include <QHash>
#include <QRect>
+#include <QObject>
#include "mythtvexp.h"
#include "mythdeque.h"
#include "tv.h"
@@ -42,8 +43,9 @@ typedef enum
typedef deque<QString> StringDeque;
typedef QHash<QString,QString> InfoMap;
-class MTV_PUBLIC PlayerContext
+class MTV_PUBLIC PlayerContext : public QObject
PlayerContext(const QString &inUseID = QString("Unknown"));
@@ -1,9 +1,10 @@
+#include <QPointer>
#include "recordingprofile.h"
#include "fifowriter.h"
#include "transcodedefs.h"
#include "programtypes.h"
+#include "playercontext.h"
-class PlayerContext;
class ProgramInfo;
class NuppelVideoRecorder;
class MythPlayer;
@@ -49,7 +50,7 @@ class Transcode : public QObject
int keyframedist;
NuppelVideoRecorder *nvr;
MythPlayer *player;
- PlayerContext *player_ctx;
+ QPointer<PlayerContext> player_ctx;
RingBuffer *inRingBuffer;
RingBuffer *outRingBuffer;
FIFOWriter *fifow;

0 comments on commit c5a9262

Please sign in to comment.