summaryrefslogtreecommitdiffstats
path: root/ash/desktop_background
diff options
context:
space:
mode:
authorbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-15 21:01:56 +0000
committerbshe@chromium.org <bshe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-15 21:01:56 +0000
commit52f885d0417ce71b7a436f00f7d805ac5997e67d (patch)
tree051cdc31e68c492b71c7b2c4f7b9ecfa2ac1245d /ash/desktop_background
parentf16aabfd9799a5c2bc684978cff1b4919b215b5b (diff)
downloadchromium_src-52f885d0417ce71b7a436f00f7d805ac5997e67d.zip
chromium_src-52f885d0417ce71b7a436f00f7d805ac5997e67d.tar.gz
chromium_src-52f885d0417ce71b7a436f00f7d805ac5997e67d.tar.bz2
Fix memory leak on Chromium OS Heapcheck and Chromium OS (valgrind)
Memcheck:Leak fun:_Znw* fun:_ZN3ash27DesktopBackgroundController16InstallComponentEPN4aura10RootWindowE fun:_ZN3ash27DesktopBackgroundController29InstallComponentForAllWindowsEv fun:_ZN3ash27DesktopBackgroundController29SetDesktopBackgroundImageModeEv fun:_ZN3ash27DesktopBackgroundController20CreateEmptyWallpaperEv fun:_ZN3ash12_GLOBAL__N_126DummyUserWallpaperDelegate19InitializeWallpaperEv fun:_ZN3ash5Shell4InitEv fun:_ZN3ash5Shell14CreateInstanceEPNS_13ShellDelegateE fun:_ZN3ash4test11AshTestBase5SetUpEv http://build.chromium.org/p/chromium.memory.fyi/builders/Chromium%20OS%20%28valgrind%29%284%29/builds/12953 BUG=141563, 141676, 142042 Review URL: https://chromiumcodereview.appspot.com/10854153 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151746 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/desktop_background')
-rw-r--r--ash/desktop_background/desktop_background_controller.cc16
-rw-r--r--ash/desktop_background/desktop_background_view.cc2
-rw-r--r--ash/desktop_background/desktop_background_widget_controller.cc10
-rw-r--r--ash/desktop_background/desktop_background_widget_controller.h7
4 files changed, 26 insertions, 9 deletions
diff --git a/ash/desktop_background/desktop_background_controller.cc b/ash/desktop_background/desktop_background_controller.cc
index 917e0ab..3df47d5 100644
--- a/ash/desktop_background/desktop_background_controller.cc
+++ b/ash/desktop_background/desktop_background_controller.cc
@@ -239,10 +239,10 @@ void DesktopBackgroundController::MoveDesktopToUnlockedContainer() {
}
void DesktopBackgroundController::OnWindowDestroying(aura::Window* window) {
- window->SetProperty(internal::kWindowDesktopComponent,
- static_cast<internal::DesktopBackgroundWidgetController*>(NULL));
- window->SetProperty(internal::kComponentWrapper,
- static_cast<internal::ComponentWrapper*>(NULL));
+ window->SetProperty(internal::kWindowDesktopComponent,
+ static_cast<internal::DesktopBackgroundWidgetController*>(NULL));
+ window->SetProperty(internal::kComponentWrapper,
+ static_cast<internal::ComponentWrapper*>(NULL));
}
void DesktopBackgroundController::SetDesktopBackgroundImageMode() {
@@ -319,7 +319,13 @@ void DesktopBackgroundController::ReparentBackgroundWidgets(int src_container,
aura::RootWindow* root_window = *iter;
if (root_window->GetProperty(internal::kComponentWrapper)) {
internal::DesktopBackgroundWidgetController* component = root_window->
- GetProperty(internal::kComponentWrapper)->component();
+ GetProperty(internal::kWindowDesktopComponent);
+ // Wallpaper animation may not finish at this point. Try to get component
+ // from kComponentWrapper instead.
+ if (!component) {
+ component = root_window->GetProperty(internal::kComponentWrapper)->
+ GetComponent(false);
+ }
DCHECK(component);
component->Reparent(root_window,
src_container,
diff --git a/ash/desktop_background/desktop_background_view.cc b/ash/desktop_background/desktop_background_view.cc
index fcbd935..5db9135 100644
--- a/ash/desktop_background/desktop_background_view.cc
+++ b/ash/desktop_background/desktop_background_view.cc
@@ -51,7 +51,7 @@ class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver {
// animation.
if (root_window_->GetProperty(kComponentWrapper)) {
internal::DesktopBackgroundWidgetController* component =
- root_window_->GetProperty(kComponentWrapper)->component();
+ root_window_->GetProperty(kComponentWrapper)->GetComponent(true);
root_window_->SetProperty(kWindowDesktopComponent, component);
}
diff --git a/ash/desktop_background/desktop_background_widget_controller.cc b/ash/desktop_background/desktop_background_widget_controller.cc
index 1d0f5fa..5d2bf71 100644
--- a/ash/desktop_background/desktop_background_widget_controller.cc
+++ b/ash/desktop_background/desktop_background_widget_controller.cc
@@ -55,7 +55,15 @@ void DesktopBackgroundWidgetController::Reparent(aura::RootWindow* root_window,
}
ComponentWrapper::ComponentWrapper(
- DesktopBackgroundWidgetController* component) : component_(component) {
+ DesktopBackgroundWidgetController* component) {
+ component_.reset(component);
+}
+
+DesktopBackgroundWidgetController* ComponentWrapper::GetComponent(
+ bool pass_ownership) {
+ if (pass_ownership)
+ return component_.release();
+ return component_.get();
}
} // namespace internal
diff --git a/ash/desktop_background/desktop_background_widget_controller.h b/ash/desktop_background/desktop_background_widget_controller.h
index c50c4fa..302e822 100644
--- a/ash/desktop_background/desktop_background_widget_controller.h
+++ b/ash/desktop_background/desktop_background_widget_controller.h
@@ -58,10 +58,13 @@ class ComponentWrapper {
explicit ComponentWrapper(
DesktopBackgroundWidgetController* component);
~ComponentWrapper() {}
- DesktopBackgroundWidgetController* component() { return component_; }
+
+ // Gets the wrapped DesktopBackgroundWidgetController pointer. Caller should
+ // take ownership of the pointer if |pass_ownership| is true.
+ DesktopBackgroundWidgetController* GetComponent(bool pass_ownership);
private:
- DesktopBackgroundWidgetController* component_;
+ scoped_ptr<DesktopBackgroundWidgetController> component_;
DISALLOW_COPY_AND_ASSIGN(ComponentWrapper);
};