Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Fix for loading the icon list in Linux #483

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions appshell/cefclient_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,18 @@ int main(int argc, char* argv[]) {
// Set window icon
std::vector<std::string> icons(APPICONS, APPICONS + sizeof(APPICONS) / sizeof(APPICONS[0]) );
GList *list = NULL;
for (int i = 0; i < icons.size(); ++i) {
std::string path = icons[i];

GdkPixbuf *icon = gdk_pixbuf_new_from_file(path.c_str(), NULL);
if (!icon)
continue;

list = g_list_append(list, icon);
for(int i = 0; i < icons.size(); ++i) {
GError *error = NULL;
std::string running_dir = AppGetRunningDirectory();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could move AppGetRunningDirectory() outside For loop.

gchar *iconpath = g_strdup_printf("%s/%s", running_dir.c_str(), icons[i].c_str());
GdkPixbuf *icon = gdk_pixbuf_new_from_file(iconpath, &error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if iconpath is NULL or not. If it is NULL continue.

g_free(iconpath);
if (!icon) {
g_printerr("Unable to create GdkPixbuf object. Reason: %s\n", error->message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radorodopski check if error is NULL or not and only then access error->message.

g_error_free(error);
continue;
}
list = g_list_append(list, icon);
}

window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
Expand Down