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:
@@ -31,13 +31,13 @@
|
||||
namespace
|
||||
{
|
||||
|
||||
#define N_RECENT 4
|
||||
auto const MaxRecentDestinations = size_t{ 4 };
|
||||
|
||||
std::list<std::string> get_recent_destinations()
|
||||
{
|
||||
std::list<std::string> list;
|
||||
|
||||
for (int i = 0; i < N_RECENT; ++i)
|
||||
for (size_t i = 0; i < MaxRecentDestinations; ++i)
|
||||
{
|
||||
auto const key = gtr_sprintf("recent-download-dir-%d", i + 1);
|
||||
|
||||
@@ -65,8 +65,8 @@ void save_recent_destination(Glib::RefPtr<Session> const& core, std::string cons
|
||||
/* add it to the front of the list */
|
||||
list.push_front(dir);
|
||||
|
||||
/* save the first N_RECENT directories */
|
||||
list.resize(N_RECENT);
|
||||
/* save the first MaxRecentDestinations directories */
|
||||
list.resize(MaxRecentDestinations);
|
||||
int i = 0;
|
||||
for (auto const& d : list)
|
||||
{
|
||||
@@ -88,6 +88,8 @@ class OptionsDialog::Impl
|
||||
public:
|
||||
Impl(OptionsDialog& dialog, Glib::RefPtr<Session> const& core, std::unique_ptr<tr_ctor, void (*)(tr_ctor*)> ctor);
|
||||
|
||||
TR_DISABLE_COPY_MOVE(Impl)
|
||||
|
||||
private:
|
||||
void sourceChanged(Gtk::FileChooserButton* b);
|
||||
void downloadDirChanged(Gtk::FileChooserButton* b);
|
||||
|
||||
Reference in New Issue
Block a user