Bug 138558

Summary: Use std::unique_ptr<>|std::make_unique_ptr in RenderThemeEfl::ThemePartCacheEntry::create()
Product: WebKit Reporter: Gyuyoung Kim <gyuyoung.kim>
Component: WebKit EFLAssignee: Gyuyoung Kim <gyuyoung.kim>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, fpizlo, lucas.de.marchi
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 128007, 138652    
Attachments:
Description Flags
Patch
none
WIP
none
Patch
none
Patch for landing none

Description Gyuyoung Kim 2014-11-09 23:24:00 PST
SSIA
Comment 1 Gyuyoung Kim 2014-11-09 23:25:08 PST
Created attachment 241279 [details]
Patch
Comment 2 Filip Pizlo 2014-11-09 23:55:15 PST
Comment on attachment 241279 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=241279&action=review

> Source/WebCore/platform/efl/RenderThemeEfl.cpp:246
> -        ThemePartCacheEntry* entry = ThemePartCacheEntry::create(themePath(), type, size).leakPtr();
> +        ThemePartCacheEntry* entry = ThemePartCacheEntry::create(themePath(), type, size).get();

get() isn't really the equivalent of get().  In particular, it seems that this will destroy ThemePartCacheEntry after this statement, leaving entry to be a dangling pointer.

Can you look into this some more?
Comment 3 Filip Pizlo 2014-11-09 23:55:40 PST
(In reply to comment #2)
> Comment on attachment 241279 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=241279&action=review
> 
> > Source/WebCore/platform/efl/RenderThemeEfl.cpp:246
> > -        ThemePartCacheEntry* entry = ThemePartCacheEntry::create(themePath(), type, size).leakPtr();
> > +        ThemePartCacheEntry* entry = ThemePartCacheEntry::create(themePath(), type, size).get();
> 
> get() isn't really the equivalent of get(). 

Lol, meant to say: get() isn't really the equivalent of leakPtr().

> In particular, it seems that
> this will destroy ThemePartCacheEntry after this statement, leaving entry to
> be a dangling pointer.
> 
> Can you look into this some more?
Comment 4 Gyuyoung Kim 2014-11-09 23:57:22 PST
(In reply to comment #2)
> Comment on attachment 241279 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=241279&action=review
> 
> > Source/WebCore/platform/efl/RenderThemeEfl.cpp:246
> > -        ThemePartCacheEntry* entry = ThemePartCacheEntry::create(themePath(), type, size).leakPtr();
> > +        ThemePartCacheEntry* entry = ThemePartCacheEntry::create(themePath(), type, size).get();
> 
> get() isn't really the equivalent of get().  In particular, it seems that
> this will destroy ThemePartCacheEntry after this statement, leaving entry to
> be a dangling pointer.
> 
> Can you look into this some more?

Ah, right. thank you for pointing it out. Let me fix it soon.
Comment 5 Gyuyoung Kim 2014-11-10 05:55:54 PST
Created attachment 241287 [details]
WIP
Comment 6 Gyuyoung Kim 2014-11-10 23:03:29 PST
Created attachment 241337 [details]
Patch
Comment 7 Gyuyoung Kim 2014-11-10 23:07:09 PST
Filip, latest patch fixes the leakPtr() removal. I removes original Eina_List with Vector<std::unique_ptr> because the Eina_List can't support std::unique_ptr. I wonder whether you can take a look this patch again.
Comment 8 Anders Carlsson 2014-11-11 06:21:42 PST
Comment on attachment 241337 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=241337&action=review

> Source/WebCore/platform/efl/RenderThemeEfl.cpp:270
> +    size_t cacheSize = m_partCache.size();
> +    for (size_t i = 0; i < cacheSize; ++i)
> +        m_partCache[i].reset();

I think you should do something like

for (auto& part : m_partCache)
    part = nullptr;

here instead.
Comment 9 Gyuyoung Kim 2014-11-11 09:03:30 PST
Created attachment 241355 [details]
Patch for landing
Comment 10 WebKit Commit Bot 2014-11-11 09:53:34 PST
Comment on attachment 241355 [details]
Patch for landing

Clearing flags on attachment: 241355

Committed r175953: <http://trac.webkit.org/changeset/175953>
Comment 11 WebKit Commit Bot 2014-11-11 09:53:38 PST
All reviewed patches have been landed.  Closing bug.