Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(776)

Side by Side Diff: chrome/common/owned_widget_gtk.cc

Issue 3013059: Fix bad conflict resolution in r54985 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/common/owned_widget_gtk.h" 5 #include "chrome/common/owned_widget_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 OwnedWidgetGtk::~OwnedWidgetGtk() { 11 OwnedWidgetGtk::~OwnedWidgetGtk() {
12 DCHECK(!widget_) << "You must explicitly call OwnerWidgetGtk::Destroy()."; 12 DCHECK(!widget_) << "You must explicitly call OwnerWidgetGtk::Destroy().";
13 } 13 }
14 14
15 void OwnedWidgetGtk::Own(GtkWidget* widget) { 15 void OwnedWidgetGtk::Own(GtkWidget* widget) {
16 if (!widget_) 16 if (!widget)
17 return; 17 return;
18 18
19 DCHECK(!widget_); 19 DCHECK(!widget_);
20 // We want to make sure that Own() was called properly, right after the 20 // We want to make sure that Own() was called properly, right after the
21 // widget was created. There should be a floating reference. 21 // widget was created. There should be a floating reference.
22 DCHECK(g_object_is_floating(widget)); 22 DCHECK(g_object_is_floating(widget));
23 23
24 // Sink the floating reference, we should now own this reference. 24 // Sink the floating reference, we should now own this reference.
25 g_object_ref_sink(widget); 25 g_object_ref_sink(widget);
26 widget_ = widget; 26 widget_ = widget;
27 } 27 }
28 28
29 void OwnedWidgetGtk::Destroy() { 29 void OwnedWidgetGtk::Destroy() {
30 if (!widget_) 30 if (!widget_)
31 return; 31 return;
32 32
33 GtkWidget* widget = widget_; 33 GtkWidget* widget = widget_;
34 widget_ = NULL; 34 widget_ = NULL;
35 gtk_widget_destroy(widget); 35 gtk_widget_destroy(widget);
36 36
37 DCHECK(!g_object_is_floating(widget)); 37 DCHECK(!g_object_is_floating(widget));
38 // NOTE: Assumes some implementation details about glib internals. 38 // NOTE: Assumes some implementation details about glib internals.
39 DCHECK_EQ(G_OBJECT(widget)->ref_count, 1U); 39 DCHECK_EQ(G_OBJECT(widget)->ref_count, 1U);
40 g_object_unref(widget); 40 g_object_unref(widget);
41 } 41 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698