Skip to content

Commit

Permalink
Refs #10311. Port MythUI to ReferenceCounter.
Browse files Browse the repository at this point in the history
Note: MythUIButtonList::GetImage() has been renamed to GetImageFilename(),
this was done to avoid conflict as getImage was renamed GetImage() and
because it is more descriptive.

As far as I can tell all MythUI leaks have now been plugged.
  • Loading branch information
daniel-kristjansson committed Jun 18, 2012
1 parent 1b8f1f3 commit 6b04160
Show file tree
Hide file tree
Showing 38 changed files with 392 additions and 266 deletions.
23 changes: 5 additions & 18 deletions mythplugins/mytharchive/mytharchive/thumbfinder.cpp
Expand Up @@ -109,7 +109,6 @@ ThumbFinder::ThumbFinder(MythScreenStack *parent, ArchiveItem *archiveItem,
m_startPTS = -1;
m_currentPTS = -1;
m_firstIFramePTS = -1;
m_image = NULL;
}

void ThumbFinder::Init(void)
Expand All @@ -124,12 +123,6 @@ ThumbFinder::~ThumbFinder()
m_thumbList.clear();

closeAVCodec();

if (m_image)
{
m_image->DownRef();
m_image = NULL;
}
}

bool ThumbFinder::Create(void)
Expand Down Expand Up @@ -891,17 +884,11 @@ bool ThumbFinder::getFrameImage(bool needKeyFrame, int64_t requiredPTS)

if (m_updateFrame)
{
if (m_image)
{
m_image->DownRef();
m_image = NULL;
}

m_image = GetMythMainWindow()->GetCurrentPainter()->GetFormatImage();
m_image->Assign(img);
m_image->UpRef();

m_frameImage->SetImage(m_image);
MythImage *mimage =
GetMythMainWindow()->GetCurrentPainter()->GetFormatImage();
mimage->Assign(img);
m_frameImage->SetImage(mimage);
mimage->DecrRef();
}

updateCurrentPos();
Expand Down
1 change: 0 additions & 1 deletion mythplugins/mytharchive/mytharchive/thumbfinder.h
Expand Up @@ -101,7 +101,6 @@ class ThumbFinder : public MythScreenType
int m_thumbCount;
QList<ThumbImage *> m_thumbList;
QString m_thumbDir;
MythImage *m_image;

// GUI stuff
MythUIButton *m_frameButton;
Expand Down
6 changes: 5 additions & 1 deletion mythplugins/mythbrowser/mythbrowser/mythbrowser.cpp
Expand Up @@ -35,6 +35,11 @@ MythBrowser::~MythBrowser()
while (!m_browserList.isEmpty())
delete m_browserList.takeFirst();
GetMythMainWindow()->PauseIdleTimer(false);
if (m_defaultFavIcon)
{
m_defaultFavIcon->DecrRef();
m_defaultFavIcon = NULL;
}
}

bool MythBrowser::Create(void)
Expand Down Expand Up @@ -70,7 +75,6 @@ bool MythBrowser::Create(void)
QImage image(favIcon);
m_defaultFavIcon = GetMythPainter()->GetFormatImage();
m_defaultFavIcon->Assign(image);
m_defaultFavIcon->UpRef();
}

// this is the template for all other browser tabs
Expand Down
8 changes: 7 additions & 1 deletion mythplugins/mythbrowser/mythbrowser/mythbrowser.h
Expand Up @@ -27,7 +27,13 @@ class MythBrowser : public MythScreenType

void setDefaultSaveDirectory(const QString saveDir) { m_defaultSaveDir = saveDir; }
void setDefaultSaveFilename(const QString saveFile) { m_defaultSaveFilename = saveFile; }
MythImage* getDefaultFavIcon(void) { return m_defaultFavIcon; }

MythImage *GetDefaultFavIcon(void)
{
if (m_defaultFavIcon)
m_defaultFavIcon->IncrRef();
return m_defaultFavIcon;
}

public slots:
void slotOpenURL(const QString &url);
Expand Down
11 changes: 8 additions & 3 deletions mythplugins/mythbrowser/mythbrowser/webpage.cpp
Expand Up @@ -100,7 +100,11 @@ void WebPage::slotIconChanged(void)
QIcon icon = m_browser->GetIcon();

if (icon.isNull())
m_listItem->setImage(m_parent->getDefaultFavIcon(), "favicon");
{
MythImage *mimage = m_parent->GetDefaultFavIcon();
m_listItem->SetImage(mimage, "favicon");
mimage->DecrRef();
}
else
{
QPixmap pixmap = icon.pixmap(32, 32);
Expand All @@ -110,7 +114,8 @@ void WebPage::slotIconChanged(void)
MythImage *mimage = GetMythPainter()->GetFormatImage();
mimage->Assign(image);

m_listItem->setImage(mimage, "favicon");
m_listItem->SetImage(mimage, "favicon");
mimage->DecrRef();
}

m_parent->m_pageList->Refresh();
Expand All @@ -120,7 +125,7 @@ void WebPage::slotLoadStarted(void)
{
m_listItem->SetText(tr("Loading..."));
m_listItem->DisplayState("loading", "loadingstate");
m_listItem->setImage(NULL, "favicon");
m_listItem->SetImage(NULL, "favicon");
m_listItem->SetImage("", "favicon");

m_parent->m_pageList->Update();
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mythmusic/mythmusic/musiccommon.cpp
Expand Up @@ -1619,7 +1619,7 @@ void MusicCommon::customEvent(QEvent *event)
if (mdata && mdata->ID() == trackID)
{
// reload the albumart image if one has already been loaded for this track
if (!item->GetImage().isEmpty())
if (!item->GetImageFilename().isEmpty())
{
QString artFile = mdata->getAlbumArtFile();
if (artFile.isEmpty())
Expand Down Expand Up @@ -1793,7 +1793,7 @@ void MusicCommon::playlistItemVisible(MythUIButtonListItem *item)
Metadata *mdata = qVariantValue<Metadata*> (item->GetData());
if (mdata)
{
if (item->GetImage().isEmpty())
if (item->GetImageFilename().isEmpty())
{
QString artFile = mdata->getAlbumArtFile();
if (artFile.isEmpty())
Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mythmusic/mythmusic/playlisteditorview.cpp
Expand Up @@ -706,7 +706,7 @@ void PlaylistEditorView::treeItemVisible(MythUIButtonListItem *item)
if (!mnode)
return;

if (item->GetImage().isEmpty())
if (item->GetImageFilename().isEmpty())
{
QString artFile;

Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mythmusic/mythmusic/searchview.cpp
Expand Up @@ -455,7 +455,7 @@ void SearchView::trackVisible(MythUIButtonListItem *item)
if (!item)
return;

if (item->GetImage().isEmpty())
if (item->GetImageFilename().isEmpty())
{
Metadata *mdata = qVariantValue<Metadata*> (item->GetData());
if (mdata)
Expand Down
2 changes: 1 addition & 1 deletion mythplugins/mythmusic/mythmusic/smartplaylist.cpp
Expand Up @@ -1752,7 +1752,7 @@ void SmartPLResultViewer::trackVisible(MythUIButtonListItem *item)
if (!item)
return;

if (item->GetImage().isEmpty())
if (item->GetImageFilename().isEmpty())
{
Metadata *mdata = qVariantValue<Metadata*> (item->GetData());
if (mdata)
Expand Down
4 changes: 2 additions & 2 deletions mythplugins/mythnetvision/mythnetvision/netsearch.cpp
Expand Up @@ -744,7 +744,7 @@ void NetSearch::slotItemChanged()
if (!item->GetThumbnail().isEmpty() && m_thumbImage)
{
MythUIButtonListItem *btn = m_searchResultList->GetItemCurrent();
QString filename = btn->GetImage();
QString filename = btn->GetImageFilename();
if (filename.contains("%SHAREDIR%"))
filename.replace("%SHAREDIR%", GetShareDir());
m_thumbImage->Reset();
Expand Down Expand Up @@ -780,7 +780,7 @@ void NetSearch::slotItemChanged()

if (m_thumbImage)
{
QString filename = item->GetImage();
QString filename = item->GetImageFilename();
m_thumbImage->Reset();
if (filename.contains("%SHAREDIR%"))
filename.replace("%SHAREDIR%", GetShareDir());
Expand Down
3 changes: 1 addition & 2 deletions mythplugins/mythzoneminder/mythzoneminder/zmclient.cpp
Expand Up @@ -511,7 +511,7 @@ void ZMClient::getEventFrame(Event *event, int frameNo, MythImage **image)
{
if (*image)
{
(*image)->DownRef();
(*image)->DecrRef();
*image = NULL;
}

Expand All @@ -538,7 +538,6 @@ void ZMClient::getEventFrame(Event *event, int frameNo, MythImage **image)

// get a MythImage
*image = GetMythMainWindow()->GetCurrentPainter()->GetFormatImage();
(*image)->UpRef();

// extract the image data and create a MythImage from it
if (!(*image)->loadFromData(data, imageSize, "JPEG"))
Expand Down
5 changes: 3 additions & 2 deletions mythplugins/mythzoneminder/mythzoneminder/zmevents.cpp
Expand Up @@ -256,7 +256,7 @@ void ZMEvents::eventChanged(MythUIButtonListItem *item)
continue;

MythUIButtonListItem *gridItem = m_eventGrid->GetItemAt(x);
if (gridItem && !gridItem->getImage())
if (gridItem && !gridItem->HasImage())
{
if (x < 0 || x > (int)m_eventList->size() - 1)
continue;
Expand All @@ -272,8 +272,9 @@ void ZMEvents::eventChanged(MythUIButtonListItem *item)
{
MythImage *mimage = GetMythPainter()->GetFormatImage();
mimage->Assign(image);
gridItem->setImage(mimage);
gridItem->SetImage(mimage);
mimage->SetChanged();
mimage->DecrRef();
}
}
}
Expand Down
17 changes: 5 additions & 12 deletions mythplugins/mythzoneminder/mythzoneminder/zmliveplayer.cpp
Expand Up @@ -390,7 +390,7 @@ void ZMLivePlayer::getMonitorList(void)

Player::Player() :
m_frameImage(NULL), m_statusText(NULL), m_cameraText(NULL),
m_image(NULL), m_rgba(NULL)
m_rgba(NULL)
{
}

Expand Down Expand Up @@ -470,17 +470,10 @@ void Player::updateFrame(const unsigned char* buffer)

QImage image(m_rgba, m_monitor.width, m_monitor.height, QImage::Format_ARGB32);

if (m_image)
{
m_image->DownRef();
m_image = NULL;
}

m_image = GetMythMainWindow()->GetCurrentPainter()->GetFormatImage();
m_image->Assign(image);
m_image->UpRef();

m_frameImage->SetImage(m_image);
MythImage *img = GetMythMainWindow()->GetCurrentPainter()->GetFormatImage();
img->Assign(image);
m_frameImage->SetImage(img);
img->DecrRef();
}

void Player::updateStatus(void)
Expand Down
2 changes: 0 additions & 2 deletions mythplugins/mythzoneminder/mythzoneminder/zmliveplayer.h
Expand Up @@ -53,8 +53,6 @@ class Player
MythUIText *m_statusText;
MythUIText *m_cameraText;

MythImage *m_image;

uchar *m_rgba;

Monitor m_monitor;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.26.20120616-1"
#define MYTH_BINARY_VERSION "0.26.20120617-1"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/Bluray/bdoverlayscreen.cpp
Expand Up @@ -120,6 +120,7 @@ void BDOverlayScreen::DisplayBDOverlay(BDOverlay *overlay)
LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("Added %1 (%2 tot)")
.arg(hash).arg(m_overlayMap.size()));
}
image->DecrRef();
}

SetRedraw();
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythtv/mhi.cpp
Expand Up @@ -526,6 +526,7 @@ void MHIContext::UpdateOSD(InteractiveScreen *osdWindow,
uiimage->SetArea(MythRect(data->m_x, data->m_y,
data->m_image.width(), data->m_image.height()));
}
image->DecrRef();
}
osdWindow->OptimiseDisplayedArea();
// N.B. bypasses OSD class hence no expiry set
Expand Down
4 changes: 4 additions & 0 deletions mythtv/libs/libmythtv/subtitlescreen.cpp
Expand Up @@ -1020,6 +1020,8 @@ int SubtitleScreen::DisplayScaledAVSubtitles(const AVSubtitleRect *rect,
m_expireTimes.insert(uiimage, displayuntil);
m_avsubCache.insert(uiimage, image);
}
image->DecrRef();
image = NULL;
}
if (uiimage)
{
Expand Down Expand Up @@ -1407,6 +1409,7 @@ void SubtitleScreen::AddScaledImage(QImage &img, QRect &pos)
uiimage->SetImage(image);
uiimage->SetArea(MythRect(scaled));
}
image->DecrRef();
}
}

Expand Down Expand Up @@ -2341,6 +2344,7 @@ void SubtitleScreen::RenderAssTrack(uint64_t timecode)
uiimage->SetImage(image);
uiimage->SetArea(MythRect(img_rect));
}
image->DecrRef();
}
images = images->next;
count++;
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmythtv/teletextscreen.cpp
Expand Up @@ -108,7 +108,7 @@ void TeletextScreen::OptimiseDisplayedArea(void)
while (it.hasNext())
{
it.next();
MythImage* image = osd_painter->GetFormatImage();
MythImage *image = osd_painter->GetFormatImage();
if (!image || !it.value())
continue;

Expand All @@ -122,6 +122,7 @@ void TeletextScreen::OptimiseDisplayedArea(void)
uiimage->SetArea(MythRect(0, row * m_rowHeight,
m_safeArea.width(), m_rowHeight * 2));
}
image->DecrRef();
}

QRegion visible;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/videooutbase.cpp
Expand Up @@ -443,7 +443,7 @@ VideoOutput::VideoOutput() :
VideoOutput::~VideoOutput()
{
if (osd_image)
osd_image->DownRef();
osd_image->DecrRef();
if (osd_painter)
delete osd_painter;

Expand Down Expand Up @@ -1355,7 +1355,7 @@ bool VideoOutput::DisplayOSD(VideoFrame *frame, OSD *osd)
if (osd_image && (osd_image->size() != osd_size))
{
LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("OSD size changed."));
osd_image->DownRef();
osd_image->DecrRef();
osd_image = NULL;
}

Expand Down

0 comments on commit 6b04160

Please sign in to comment.