Qt can do a lot of work in a 'new object()' then most

From: Erik Hovland <erik@hovland.org>

libraries. So you often see all sorts of new calls
in Qt that don't actually assign the pointer. Don't worry,
Qt will automagically clean it up later.

Anyhow, it seems that the OSDGenericTree class is
designed much the same. So the assignments of these
new objects are superfluous.
---

 libs/libmythtv/NuppelVideoPlayer.cpp |    6 -
 libs/libmythtv/tv_play.cpp           |  213 +++++++++++++++-------------------
 2 files changed, 96 insertions(+), 123 deletions(-)

diff --git a/libs/libmythtv/NuppelVideoPlayer.cpp b/libs/libmythtv/NuppelVideoPlayer.cpp
index 6c52cc7..e59ab11 100644
--- a/libs/libmythtv/NuppelVideoPlayer.cpp
+++ b/libs/libmythtv/NuppelVideoPlayer.cpp
@@ -6680,17 +6680,15 @@ void NuppelVideoPlayer::ChangeCaptionTrack(int dir)
  */
 void NuppelVideoPlayer::DisplayAVSubtitles(void)
 {
-    OSDSet *subtitleOSD;
+    OSDSet *subtitleOSD = osd->GetSet("subtitles");
     bool setVisible = false;
     VideoFrame *currentFrame = videoOutput->GetLastShownFrame();
 
-    if (!osd || !currentFrame || !(subtitleOSD = osd->GetSet("subtitles")))
+    if (!osd || !currentFrame || !subtitleOSD)
         return;
 
     subtitleLock.lock();
 
-    subtitleOSD = osd->GetSet("subtitles");
-
     // hide the subs if they have been long enough in the screen without
     // new subtitles replacing them
     if (osdHasSubtitles && currentFrame->timecode >= osdSubtitlesExpireAt) 
diff --git a/libs/libmythtv/tv_play.cpp b/libs/libmythtv/tv_play.cpp
index de6ebdd..9794412 100644
--- a/libs/libmythtv/tv_play.cpp
+++ b/libs/libmythtv/tv_play.cpp
@@ -7488,7 +7488,7 @@ void TV::BuildOSDTreeMenu(void)
         delete treeMenu;
 
     treeMenu = new OSDGenericTree(NULL, "treeMenu");
-    OSDGenericTree *item, *subitem;
+    OSDGenericTree *item;
 
     if (StateIsLiveTV(GetState()))
         FillMenuLiveTV(treeMenu);
@@ -7520,9 +7520,9 @@ void TV::BuildOSDTreeMenu(void)
 
         bool sel = (i != kAspect_Off) ? (aspectoverride == i) :
             (aspectoverride <= kAspect_Off) || (aspectoverride >= kAspect_END);
-        subitem = new OSDGenericTree(item, toString((AspectOverrideMode) i),
-                                     QString("TOGGLEASPECT%1").arg(i),
-                                     (sel) ? 1 : 0, NULL, "ASPECTGROUP");
+        new OSDGenericTree(item, toString((AspectOverrideMode) i),
+                           QString("TOGGLEASPECT%1").arg(i),
+                           (sel) ? 1 : 0, NULL, "ASPECTGROUP");
     }
 
     AdjustFillMode adjustfill = nvp->GetAdjustFill();
@@ -7531,9 +7531,9 @@ void TV::BuildOSDTreeMenu(void)
     {
         bool sel = (i != kAdjustFill_Off) ? (adjustfill == i) :
             (adjustfill <= kAdjustFill_Off) || (adjustfill >= kAdjustFill_END);
-        subitem = new OSDGenericTree(item, toString((AdjustFillMode) i),
-                                     QString("TOGGLEFILL%1").arg(i),
-                                     (sel) ? 1 : 0, NULL, "ADJUSTFILLGROUP");
+        new OSDGenericTree(item, toString((AdjustFillMode) i),
+                           QString("TOGGLEFILL%1").arg(i),
+                           (sel) ? 1 : 0, NULL, "ADJUSTFILLGROUP");
     }
 
     uint sup = kPictureAttributeSupported_None;
@@ -7546,46 +7546,45 @@ void TV::BuildOSDTreeMenu(void)
         {
             if (!item)
                 item = new OSDGenericTree(treeMenu, tr("Adjust Picture"));
-            subitem = new OSDGenericTree(
-                item, toString((PictureAttribute) i),
-                QString("TOGGLEPICCONTROLS%1").arg(i));
+
+            new OSDGenericTree(item, toString((PictureAttribute) i),
+                               QString("TOGGLEPICCONTROLS%1").arg(i));
         }
     }
 
-    item = new OSDGenericTree(treeMenu, tr("Manual Zoom Mode"), 
-                             "TOGGLEMANUALZOOM");
+    new OSDGenericTree(treeMenu, tr("Manual Zoom Mode"), "TOGGLEMANUALZOOM");
 
     item = new OSDGenericTree(treeMenu, tr("Adjust Audio Sync"), "TOGGLEAUDIOSYNC");
 
     int speedX100 = (int)(round(normal_speed * 100));
 
     item = new OSDGenericTree(treeMenu, tr("Adjust Time Stretch"), "ADJUSTSTRETCH");
-    subitem = new OSDGenericTree(item, tr("Toggle"), "TOGGLESTRETCH");
-    subitem = new OSDGenericTree(item, tr("Adjust"), "ADJUSTSTRETCH");
-    subitem = new OSDGenericTree(item, tr("0.5X"), "ADJUSTSTRETCH0.5",
-                                 (speedX100 == 50) ? 1 : 0, NULL,
-                                 "STRETCHGROUP");
-    subitem = new OSDGenericTree(item, tr("0.9X"), "ADJUSTSTRETCH0.9",
-                                 (speedX100 == 90) ? 1 : 0, NULL,
-                                 "STRETCHGROUP");
-    subitem = new OSDGenericTree(item, tr("1.0X"), "ADJUSTSTRETCH1.0",
-                                 (speedX100 == 100) ? 1 : 0, NULL,
-                                 "STRETCHGROUP");
-    subitem = new OSDGenericTree(item, tr("1.1X"), "ADJUSTSTRETCH1.1",
-                                 (speedX100 == 110) ? 1 : 0, NULL,
-                                 "STRETCHGROUP");
-    subitem = new OSDGenericTree(item, tr("1.2X"), "ADJUSTSTRETCH1.2",
-                                 (speedX100 == 120) ? 1 : 0, NULL,
-                                 "STRETCHGROUP");
-    subitem = new OSDGenericTree(item, tr("1.3X"), "ADJUSTSTRETCH1.3",
-                                 (speedX100 == 130) ? 1 : 0, NULL,
-                                 "STRETCHGROUP");
-    subitem = new OSDGenericTree(item, tr("1.4X"), "ADJUSTSTRETCH1.4",
-                                 (speedX100 == 140) ? 1 : 0, NULL,
-                                 "STRETCHGROUP");
-    subitem = new OSDGenericTree(item, tr("1.5X"), "ADJUSTSTRETCH1.5",
-                                 (speedX100 == 150) ? 1 : 0, NULL,
-                                 "STRETCHGROUP");
+    new OSDGenericTree(item, tr("Toggle"), "TOGGLESTRETCH");
+    OSDGenericTree(item, tr("Adjust"), "ADJUSTSTRETCH");
+    new OSDGenericTree(item, tr("0.5X"), "ADJUSTSTRETCH0.5",
+                       (speedX100 == 50) ? 1 : 0, NULL,
+                       "STRETCHGROUP");
+    new OSDGenericTree(item, tr("0.9X"), "ADJUSTSTRETCH0.9",
+                       (speedX100 == 90) ? 1 : 0, NULL,
+                       "STRETCHGROUP");
+    new OSDGenericTree(item, tr("1.0X"), "ADJUSTSTRETCH1.0",
+                       (speedX100 == 100) ? 1 : 0, NULL,
+                       "STRETCHGROUP");
+    new OSDGenericTree(item, tr("1.1X"), "ADJUSTSTRETCH1.1",
+                       (speedX100 == 110) ? 1 : 0, NULL,
+                       "STRETCHGROUP");
+    new OSDGenericTree(item, tr("1.2X"), "ADJUSTSTRETCH1.2",
+                       (speedX100 == 120) ? 1 : 0, NULL,
+                       "STRETCHGROUP");
+    new OSDGenericTree(item, tr("1.3X"), "ADJUSTSTRETCH1.3",
+                       (speedX100 == 130) ? 1 : 0, NULL,
+                       "STRETCHGROUP");
+    new OSDGenericTree(item, tr("1.4X"), "ADJUSTSTRETCH1.4",
+                       (speedX100 == 140) ? 1 : 0, NULL,
+                       "STRETCHGROUP");
+    new OSDGenericTree(item, tr("1.5X"), "ADJUSTSTRETCH1.5",
+                       (speedX100 == 150) ? 1 : 0, NULL,
+                       "STRETCHGROUP");
 
     // add scan mode override settings to menu
     FrameScanType scan_type = kScan_Ignore;
@@ -7610,33 +7609,30 @@ void TV::BuildOSDTreeMenu(void)
 
     item = new OSDGenericTree(
         treeMenu, tr("Video Scan"), "SCANMODE");
-    subitem = new OSDGenericTree(
-        item, tr("Detect") + cur_mode, "SELECTSCAN_0",
+    new OSDGenericTree(item, tr("Detect") + cur_mode, "SELECTSCAN_0",
         (scan_type == kScan_Detect) ? 1 : 0, NULL, "SCANGROUP");
-    subitem = new OSDGenericTree(
-        item, tr("Progressive"), "SELECTSCAN_3",
+    new OSDGenericTree(item, tr("Progressive"), "SELECTSCAN_3",
         (scan_type == kScan_Progressive) ? 1 : 0, NULL, "SCANGROUP");
-    subitem = new OSDGenericTree(
-        item, tr("Interlaced (Normal)"), "SELECTSCAN_1",
+    new OSDGenericTree(item, tr("Interlaced (Normal)"), "SELECTSCAN_1",
         (scan_type == kScan_Interlaced) ? 1 : 0, NULL, "SCANGROUP");
-    subitem = new OSDGenericTree(
-        item, tr("Interlaced (Reversed)"), "SELECTSCAN_2",
+    new OSDGenericTree(item, tr("Interlaced (Reversed)"), "SELECTSCAN_2",
         (scan_type == kScan_Intr2ndField) ? 1 : 0, NULL, "SCANGROUP");
     
     // add sleep items to menu
 
     item = new OSDGenericTree(treeMenu, tr("Sleep"), "TOGGLESLEEPON");
     if (sleepTimer.isRunning())
-        subitem = new OSDGenericTree(item, tr("Sleep Off"), "TOGGLESLEEPON");
-    subitem = new OSDGenericTree(item, "30 " + tr("minutes"), "TOGGLESLEEP30");
-    subitem = new OSDGenericTree(item, "60 " + tr("minutes"), "TOGGLESLEEP60");
-    subitem = new OSDGenericTree(item, "90 " + tr("minutes"), "TOGGLESLEEP90");
-    subitem = new OSDGenericTree(item, "120 " + tr("minutes"), "TOGGLESLEEP120");
+        new OSDGenericTree(item, tr("Sleep Off"), "TOGGLESLEEPON");
+
+    new OSDGenericTree(item, "30 " + tr("minutes"), "TOGGLESLEEP30");
+    new OSDGenericTree(item, "60 " + tr("minutes"), "TOGGLESLEEP60");
+    new OSDGenericTree(item, "90 " + tr("minutes"), "TOGGLESLEEP90");
+    new OSDGenericTree(item, "120 " + tr("minutes"), "TOGGLESLEEP120");
 }
 
 void TV::FillMenuLiveTV(OSDGenericTree *treeMenu)
 {
-    OSDGenericTree *item, *subitem;
+    OSDGenericTree *item;
 
     bool freeRecorders = (pipnvp != NULL);
     if (!freeRecorders)
@@ -7647,19 +7643,19 @@ void TV::FillMenuLiveTV(OSDGenericTree *treeMenu)
     if (!gContext->GetNumSetting("JumpToProgramOSD", 1))
     {
         item = new OSDGenericTree(treeMenu, tr("Jump to Program"));
-        subitem = new OSDGenericTree(item, tr("Recorded Program"), "JUMPREC");
+        new OSDGenericTree(item, tr("Recorded Program"), "JUMPREC");
         if (lastProgram != NULL)
-            subitem = new OSDGenericTree(item, lastProgram->title, "JUMPPREV");
+            new OSDGenericTree(item, lastProgram->title, "JUMPPREV");
     }
 
     if (freeRecorders)
     {
         // Picture-in-Picture
         item = new OSDGenericTree(treeMenu, tr("Picture-in-Picture"));
-        subitem = new OSDGenericTree(item, tr("Enable/Disable"),
+        new OSDGenericTree(item, tr("Enable/Disable"),
                                      "TOGGLEPIPMODE");
-        subitem = new OSDGenericTree(item, tr("Swap PiP/Main"), "SWAPPIP");
-        subitem = new OSDGenericTree(item, tr("Change Active Window"),
+        new OSDGenericTree(item, tr("Swap PiP/Main"), "SWAPPIP");
+        new OSDGenericTree(item, tr("Change Active Window"),
                                      "TOGGLEPIPWINDOW");
 
         // Input switching
@@ -7714,9 +7710,9 @@ void TV::FillMenuLiveTV(OSDGenericTree *treeMenu)
                         tr("I", "Input") + ":" + inputs[i].name;
                 }
 
-                subitem = new OSDGenericTree(
-                    item, name,
-                    QString("SWITCHTOINPUT_%1").arg(inputs[i].inputid));
+                new OSDGenericTree(item, name,
+                                   QString("SWITCHTOINPUT_%1")
+                                       .arg(inputs[i].inputid));
             }
         }
 
@@ -7731,32 +7727,26 @@ void TV::FillMenuLiveTV(OSDGenericTree *treeMenu)
             item = new OSDGenericTree(treeMenu, tr("Switch Source"));
         for (; sit != sources.end(); ++sit)
         {
-            subitem = new OSDGenericTree(
-                item, SourceUtil::GetSourceName((*sit).sourceid),
-                QString("SWITCHTOINPUT_%1").arg((*sit).inputid));
+            new OSDGenericTree(item, SourceUtil::GetSourceName((*sit).sourceid),
+                               QString("SWITCHTOINPUT_%1").arg((*sit).inputid));
         }
     }
 
     if (!persistentbrowsemode)
-    {
-        item = new OSDGenericTree(
-            treeMenu, tr("Enable Browse Mode"), "TOGGLEBROWSE");
-    }
+        new OSDGenericTree(treeMenu, tr("Enable Browse Mode"), "TOGGLEBROWSE");
 
-    item = new OSDGenericTree(treeMenu, tr("Previous Channel"),
-                              "PREVCHAN");
+    new OSDGenericTree(treeMenu, tr("Previous Channel"), "PREVCHAN");
 }
 
 void TV::FillMenuPlaying(OSDGenericTree *treeMenu)
 {
-    OSDGenericTree *item, *subitem;
+    OSDGenericTree *item;
 
     if (activerbuffer && activerbuffer->isDVD())
     {
-        item = new OSDGenericTree(
-            treeMenu, tr("DVD Root Menu"),    "JUMPTODVDROOTMENU");
-        item = new OSDGenericTree(
-            treeMenu, tr("DVD Chapter Menu"), "JUMPTODVDCHAPTERMENU");
+        new OSDGenericTree(treeMenu, tr("DVD Root Menu"), "JUMPTODVDROOTMENU");
+        new OSDGenericTree(treeMenu,tr("DVD Chapter Menu"),
+                           "JUMPTODVDCHAPTERMENU");
 
         return;
     }
@@ -7765,67 +7755,54 @@ void TV::FillMenuPlaying(OSDGenericTree *treeMenu)
 
     item = new OSDGenericTree(treeMenu, tr("Jump to Program"));
 
-    subitem = new OSDGenericTree(item, tr("Recorded Program"), "JUMPREC");
+    new OSDGenericTree(item, tr("Recorded Program"), "JUMPREC");
     if (lastProgram != NULL)
-        subitem = new OSDGenericTree(item, lastProgram->title, "JUMPPREV");
+        new OSDGenericTree(item, lastProgram->title, "JUMPPREV");
 
     pbinfoLock.lock();
 
     if (JobQueue::IsJobQueuedOrRunning(
             JOB_TRANSCODE, playbackinfo->chanid, playbackinfo->startts))
     {
-        item = new OSDGenericTree(treeMenu, tr("Stop Transcoding"),
-                                  "QUEUETRANSCODE");
+        new OSDGenericTree(treeMenu, tr("Stop Transcoding"), "QUEUETRANSCODE");
     }
     else
     {
         item = new OSDGenericTree(treeMenu, tr("Begin Transcoding"));
-        subitem = new OSDGenericTree(item, tr("Default"),
-                                     "QUEUETRANSCODE");
-        subitem = new OSDGenericTree(item, tr("Autodetect"),
-                                     "QUEUETRANSCODE_AUTO");
-        subitem = new OSDGenericTree(item, tr("High Quality"),
-                                     "QUEUETRANSCODE_HIGH");
-        subitem = new OSDGenericTree(item, tr("Medium Quality"),
-                                     "QUEUETRANSCODE_MEDIUM");
-        subitem = new OSDGenericTree(item, tr("Low Quality"),
-                                     "QUEUETRANSCODE_LOW");
+        new OSDGenericTree(item, tr("Default"), "QUEUETRANSCODE");
+        new OSDGenericTree(item, tr("Autodetect"), "QUEUETRANSCODE_AUTO");
+        new OSDGenericTree(item, tr("High Quality"), "QUEUETRANSCODE_HIGH");
+        new OSDGenericTree(item, tr("Medium Quality"), "QUEUETRANSCODE_MEDIUM");
+        new OSDGenericTree(item, tr("Low Quality"), "QUEUETRANSCODE_LOW");
     }
 
     item = new OSDGenericTree(treeMenu, tr("Commercial Auto-Skip"));
-    subitem = new OSDGenericTree(item, tr("Auto-Skip OFF"),
-                                 "TOGGLECOMMSKIP0",
-                                 (autoCommercialSkip == 0) ? 1 : 0, NULL,
-                                 "COMMSKIPGROUP");
-    subitem = new OSDGenericTree(item, tr("Auto-Skip Notify"),
-                                 "TOGGLECOMMSKIP2",
-                                 (autoCommercialSkip == 2) ? 1 : 0, NULL,
-                                 "COMMSKIPGROUP");
-    subitem = new OSDGenericTree(item, tr("Auto-Skip ON"),
-                                 "TOGGLECOMMSKIP1",
-                                 (autoCommercialSkip == 1) ? 1 : 0, NULL,
-                                 "COMMSKIPGROUP");
+    new OSDGenericTree(item, tr("Auto-Skip OFF"), "TOGGLECOMMSKIP0",
+                       (autoCommercialSkip == 0) ? 1 : 0, NULL,
+                       "COMMSKIPGROUP");
+    new OSDGenericTree(item, tr("Auto-Skip Notify"), "TOGGLECOMMSKIP2",
+                       (autoCommercialSkip == 2) ? 1 : 0, NULL,
+                       "COMMSKIPGROUP");
+    new OSDGenericTree(item, tr("Auto-Skip ON"), "TOGGLECOMMSKIP1",
+                       (autoCommercialSkip == 1) ? 1 : 0, NULL,
+                       "COMMSKIPGROUP");
 
     if (playbackinfo->GetAutoExpireFromRecorded())
     {
-        item = new OSDGenericTree(treeMenu, tr("Turn Auto-Expire OFF"),
-                                  "TOGGLEAUTOEXPIRE");
+        new OSDGenericTree(treeMenu, tr("Turn Auto-Expire OFF"),
+                           "TOGGLEAUTOEXPIRE");
     }
     else
-    {
         item = new OSDGenericTree(treeMenu, tr("Turn Auto-Expire ON"),
                                   "TOGGLEAUTOEXPIRE");
-    }
 
     pbinfoLock.unlock();
 
     item = new OSDGenericTree(treeMenu, tr("Schedule Recordings"));
-    subitem = new OSDGenericTree(item, tr("Program Guide"), "GUIDE");
-    subitem = new OSDGenericTree(item, tr("Upcoming Recordings"), 
-                                "VIEWSCHEDULED");
-    subitem = new OSDGenericTree(item, tr("Program Finder"), "FINDER");
-    subitem = new OSDGenericTree(item, tr("Edit Recording Schedule"),
-                                 "SCHEDULE");
+    new OSDGenericTree(item, tr("Program Guide"), "GUIDE");
+    new OSDGenericTree(item, tr("Upcoming Recordings"), "VIEWSCHEDULED");
+    new OSDGenericTree(item, tr("Program Finder"), "FINDER");
+    new OSDGenericTree(item, tr("Edit Recording Schedule"), "SCHEDULE");
 }
 
 bool TV::FillMenuTracks(OSDGenericTree *treeMenu, uint type)
@@ -7876,9 +7853,7 @@ bool TV::FillMenuTracks(OSDGenericTree *treeMenu, uint type)
         sel     = activenvp->GetCaptionMode() & kTrackTypeTeletextCaptions;
     }
     else
-    {
         return false;
-    }
     
     const QStringList tracks = activenvp->GetTracks(type);
     if (tracks.empty())
@@ -8682,7 +8657,7 @@ void TV::DoDisplayJumpMenu(void)
         delete treeMenu;
 
      treeMenu = new OSDGenericTree(NULL, "treeMenu"); 
-     OSDGenericTree *item, *subitem; 
+     OSDGenericTree *item; 
    
      // Build jumpMenu of recorded program titles 
         ProgramInfo *p; 
@@ -8711,8 +8686,8 @@ void TV::DoDisplayJumpMenu(void)
             int progIndex = plist.count(); 
             if (progIndex == 1) 
             {  
-                item = new OSDGenericTree(treeMenu, tr(Iprog.key()), 
-                    QString("JUMPPROG %1 0").arg(Iprog.key())); 
+                new OSDGenericTree(treeMenu, tr(Iprog.key()), 
+                                   QString("JUMPPROG %1 0").arg(Iprog.key()));
             }  
             else  
             { 
@@ -8721,11 +8696,11 @@ void TV::DoDisplayJumpMenu(void)
                 { 
                     p = plist.at(i); 
                     if (p->subtitle != "") 
-                        subitem = new OSDGenericTree(item, tr(p->subtitle),  
-                            QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i)); 
+                        new OSDGenericTree(item, tr(p->subtitle),  
+                            QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i));
                     else  
-                        subitem = new OSDGenericTree(item, tr(p->title),  
-                            QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i)); 
+                        new OSDGenericTree(item, tr(p->title),  
+                            QString("JUMPPROG %1 %2").arg(Iprog.key()).arg(i));
                 } 
             } 
         } 
