<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - Template Manager memory leak in TemplateLocalView::insertItems()"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=111567">111567</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Template Manager memory leak in TemplateLocalView::insertItems()
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.0.0.0.alpha0+ Master
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Mac OS X (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>framework
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>iplaw67@tuta.io
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Description:
When initiating the TemplateManager, and then moving through the dropdown
filter to filter templates according to application module, multiple instances
of memory leaks occur in 

TemplateLocalView::insertItems()

Steps to Reproduce:
1. Start XCode, then Instruments.app
2. Choose Memory Leak profile tool
3. Select LibreOffice.app in instdir as target process
4. Click on the record button, LODev is started by the profiling tool
5. Wait for the StartCenter to load - note the occurrences of memory leaks as
they occur.
6. Open the template manager from the left dropdown menu.
7. When the Template Manager has loaded, cycle between the various application
module filters using the dropdown menu.
8. Close the template manager window.
9. Stop recording.
10. Analyse the profile trace.

Actual Results:  
Multiple instances of memory leaks occur in 

TemplateLocalView::insertItems()

when instantiating and navigating through the template filter.

Expected Results:
It shouldn't leak memory


Reproducible: Always

User Profile Reset: No

Additional Info:
The problem appears to lie in templatelocalview.cxx in this block of code :

void TemplateLocalView::insertItems(const std::vector<TemplateItemProperties>
&rTemplates, bool isRegionSelected, bool bShowCategoryInTooltip)
{
    mItemList.clear();

    std::vector<ThumbnailViewItem*> aItems(rTemplates.size());
    for (size_t i = 0, n = rTemplates.size(); i < n; ++i )
    {
        const TemplateItemProperties *pCur = &rTemplates[i];

        TemplateViewItem *pChild;
        if(isRegionSelected)
            pChild = new TemplateViewItem(*this, pCur->nId);
        else
            pChild = new TemplateViewItem(*this, i+1);

        pChild->mnDocId = pCur->nDocId;
        pChild->mnRegionId = pCur->nRegionId;
        pChild->maTitle = pCur->aName;
        pChild->setPath(pCur->aPath);




and in particularly with this line :

            pChild = new TemplateViewItem(*this, i+1);



User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0)
Gecko/20100101 Firefox/54.0</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>