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

Unified Diff: chrome/browser/gtk/bookmark_bubble_gtk.cc

Issue 335032: Add a check for NULL in PopulateFolderCombo. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/gtk/bookmark_bubble_gtk.cc
===================================================================
--- chrome/browser/gtk/bookmark_bubble_gtk.cc (revision 30067)
+++ chrome/browser/gtk/bookmark_bubble_gtk.cc (working copy)
@@ -36,10 +36,10 @@
std::vector<const BookmarkNode*> PopulateFolderCombo(BookmarkModel* model,
const GURL& url,
GtkWidget* folder_combo) {
- const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url);
- const BookmarkNode* parent = node->GetParent();
const BookmarkNode* bookmark_bar = model->GetBookmarkBarNode();
const BookmarkNode* other = model->other_node();
+ const BookmarkNode* node = model->GetMostRecentlyAddedNodeForURL(url);
+ const BookmarkNode* parent = node ? node->GetParent() : NULL;
// Use + 2 to account for bookmark bar and other node.
std::vector<const BookmarkNode*> recent_nodes =
@@ -47,7 +47,7 @@
std::vector<const BookmarkNode*> nodes;
// Make the parent the first item, unless it's the bookmark bar or other node.
- if (parent != bookmark_bar && parent != other)
+ if (parent && parent != bookmark_bar && parent != other)
nodes.push_back(parent);
for (size_t i = 0; i < recent_nodes.size(); ++i) {
@@ -75,8 +75,11 @@
l10n_util::GetStringUTF8(
IDS_BOOMARK_BUBBLE_CHOOSER_ANOTHER_FOLDER).c_str());
- int parent_index = static_cast<int>(
- std::find(nodes.begin(), nodes.end(), parent) - nodes.begin());
+ gint parent_index = 0;
+ if (parent) {
+ parent_index = static_cast<gint>(
+ std::find(nodes.begin(), nodes.end(), parent) - nodes.begin());
+ }
gtk_combo_box_set_active(GTK_COMBO_BOX(folder_combo), parent_index);
return nodes;
« 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