Permalink
Browse files

Refs #10311. Port MythUI to ReferenceCounter.

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 6b04160ac3ad1666cd034aa809ed5bb939a2028c
Showing with 392 additions and 266 deletions.
  1. +5 −18 mythplugins/mytharchive/mytharchive/thumbfinder.cpp
  2. +0 −1 mythplugins/mytharchive/mytharchive/thumbfinder.h
  3. +5 −1 mythplugins/mythbrowser/mythbrowser/mythbrowser.cpp
  4. +7 −1 mythplugins/mythbrowser/mythbrowser/mythbrowser.h
  5. +8 −3 mythplugins/mythbrowser/mythbrowser/webpage.cpp
  6. +2 −2 mythplugins/mythmusic/mythmusic/musiccommon.cpp
  7. +1 −1 mythplugins/mythmusic/mythmusic/playlisteditorview.cpp
  8. +1 −1 mythplugins/mythmusic/mythmusic/searchview.cpp
  9. +1 −1 mythplugins/mythmusic/mythmusic/smartplaylist.cpp
  10. +2 −2 mythplugins/mythnetvision/mythnetvision/netsearch.cpp
  11. +1 −2 mythplugins/mythzoneminder/mythzoneminder/zmclient.cpp
  12. +3 −2 mythplugins/mythzoneminder/mythzoneminder/zmevents.cpp
  13. +5 −12 mythplugins/mythzoneminder/mythzoneminder/zmliveplayer.cpp
  14. +0 −2 mythplugins/mythzoneminder/mythzoneminder/zmliveplayer.h
  15. +1 −1 mythtv/libs/libmythbase/mythversion.h
  16. +1 −0 mythtv/libs/libmythtv/Bluray/bdoverlayscreen.cpp
  17. +1 −0 mythtv/libs/libmythtv/mhi.cpp
  18. +4 −0 mythtv/libs/libmythtv/subtitlescreen.cpp
  19. +2 −1 mythtv/libs/libmythtv/teletextscreen.cpp
  20. +2 −2 mythtv/libs/libmythtv/videooutbase.cpp
  21. +29 −41 mythtv/libs/libmythui/mythimage.cpp
  22. +12 −9 mythtv/libs/libmythui/mythimage.h
  23. +88 −25 mythtv/libs/libmythui/mythpainter.cpp
  24. +6 −2 mythtv/libs/libmythui/mythpainter.h
  25. +7 −3 mythtv/libs/libmythui/mythpainter_qt.cpp
  26. +29 −0 mythtv/libs/libmythui/mythpainter_yuva.cpp
  27. +30 −29 mythtv/libs/libmythui/mythuibuttonlist.cpp
  28. +16 −6 mythtv/libs/libmythui/mythuibuttonlist.h
  29. +6 −2 mythtv/libs/libmythui/mythuiguidegrid.cpp
  30. +35 −46 mythtv/libs/libmythui/mythuihelper.cpp
  31. +4 −0 mythtv/libs/libmythui/mythuihelper.h
  32. +49 −40 mythtv/libs/libmythui/mythuiimage.cpp
  33. +18 −2 mythtv/libs/libmythui/mythuiimage.h
  34. +2 −2 mythtv/libs/libmythui/mythuivideo.cpp
  35. +4 −1 mythtv/libs/libmythui/mythuiwebbrowser.cpp
  36. +3 −3 mythtv/programs/mythfrontend/playbackbox.cpp
  37. +1 −1 mythtv/programs/mythtv-setup/channeleditor.cpp
  38. +1 −1 mythtv/programs/mythtv-setup/importicons.cpp
@@ -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)
@@ -124,12 +123,6 @@ ThumbFinder::~ThumbFinder()
m_thumbList.clear();
closeAVCodec();
-
- if (m_image)
- {
- m_image->DownRef();
- m_image = NULL;
- }
}
bool ThumbFinder::Create(void)
@@ -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();
@@ -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;
@@ -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)
@@ -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
@@ -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);
@@ -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);
@@ -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();
@@ -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();
@@ -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())
@@ -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())
@@ -706,7 +706,7 @@ void PlaylistEditorView::treeItemVisible(MythUIButtonListItem *item)
if (!mnode)
return;
- if (item->GetImage().isEmpty())
+ if (item->GetImageFilename().isEmpty())
{
QString artFile;
@@ -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)
@@ -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)
@@ -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();
@@ -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());
@@ -511,7 +511,7 @@ void ZMClient::getEventFrame(Event *event, int frameNo, MythImage **image)
{
if (*image)
{
- (*image)->DownRef();
+ (*image)->DecrRef();
*image = NULL;
}
@@ -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"))
@@ -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;
@@ -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();
}
}
}
@@ -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)
{
}
@@ -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)
@@ -53,8 +53,6 @@ class Player
MythUIText *m_statusText;
MythUIText *m_cameraText;
- MythImage *m_image;
-
uchar *m_rgba;
Monitor m_monitor;
@@ -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.
*
@@ -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();
@@ -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
@@ -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)
{
@@ -1407,6 +1409,7 @@ void SubtitleScreen::AddScaledImage(QImage &img, QRect &pos)
uiimage->SetImage(image);
uiimage->SetArea(MythRect(scaled));
}
+ image->DecrRef();
}
}
@@ -2341,6 +2344,7 @@ void SubtitleScreen::RenderAssTrack(uint64_t timecode)
uiimage->SetImage(image);
uiimage->SetArea(MythRect(img_rect));
}
+ image->DecrRef();
}
images = images->next;
count++;
@@ -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;
@@ -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;
@@ -443,7 +443,7 @@ VideoOutput::VideoOutput() :
VideoOutput::~VideoOutput()
{
if (osd_image)
- osd_image->DownRef();
+ osd_image->DecrRef();
if (osd_painter)
delete osd_painter;
@@ -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;
}
Oops, something went wrong.

0 comments on commit 6b04160

Please sign in to comment.