mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 20:35:36 +00:00
Fix most of critical issues reported by Sonar (GTK client) (#2309)
* (C++) Macros should not be used to define constants * (C++) Memory should not be managed manually * (C++) "void*" should not be used in typedefs, member variables, function parameters or return type * (C++) When the "Rule-of-Zero" is not applicable, the "Rule-of-Five" should be followed * (C++) "switch" statements should have "default" clauses * (C++) "explicit" should be used on single-parameter constructors and conversiosn operators * (C++) Non-const global variables should not be used
This commit is contained in:
@@ -14,11 +14,16 @@
|
||||
#include "IconCache.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#define VOID_PIXBUF_KEY "void-pixbuf"
|
||||
using namespace std::literals;
|
||||
|
||||
Glib::ustring const DirectoryMimeType = "folder"s;
|
||||
Glib::ustring const UnknownMimeType = "unknown"s;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
auto const VoidPixbufKey = "void-pixbuf"s;
|
||||
|
||||
struct IconCache
|
||||
{
|
||||
Glib::RefPtr<Gtk::IconTheme> icon_theme;
|
||||
@@ -48,7 +53,7 @@ std::unique_ptr<IconCache> icon_cache_new(Gtk::Widget& for_widget, Gtk::IconSize
|
||||
auto icons = std::make_unique<IconCache>();
|
||||
icons->icon_theme = Gtk::IconTheme::get_for_screen(for_widget.get_screen());
|
||||
icons->icon_size = get_size_in_pixels(icon_size);
|
||||
icons->cache.emplace(VOID_PIXBUF_KEY, create_void_pixbuf(icons->icon_size, icons->icon_size));
|
||||
icons->cache.emplace(VoidPixbufKey, create_void_pixbuf(icons->icon_size, icons->icon_size));
|
||||
return icons;
|
||||
}
|
||||
|
||||
@@ -134,7 +139,7 @@ Glib::RefPtr<Gdk::Pixbuf> icon_cache_get_mime_type_icon(IconCache& icons, Glib::
|
||||
auto key = _icon_cache_get_icon_key(icon);
|
||||
if (key.empty())
|
||||
{
|
||||
key = VOID_PIXBUF_KEY;
|
||||
key = VoidPixbufKey;
|
||||
}
|
||||
|
||||
if (auto pixbuf_it = icons.cache.find(key); pixbuf_it != icons.cache.end())
|
||||
|
||||
Reference in New Issue
Block a user