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:
Mike Gelfand
2021-12-14 11:43:27 +03:00
committed by GitHub
parent 7015f48798
commit 3e072f9bd4
82 changed files with 459 additions and 287 deletions

View File

@@ -19,11 +19,11 @@
#include "Session.h"
#include "Utils.h"
#define FILE_CHOSEN_KEY "file-is-chosen"
namespace
{
auto const FileChosenKey = Glib::Quark("file-is-chosen");
class MakeProgressDialog : public Gtk::Dialog
{
public:
@@ -34,6 +34,8 @@ public:
Glib::RefPtr<Session> const& core);
~MakeProgressDialog() override;
TR_DISABLE_COPY_MOVE(MakeProgressDialog)
private:
bool onProgressDialogRefresh();
void onProgressDialogResponse(int response);
@@ -57,6 +59,8 @@ class MakeDialog::Impl
public:
Impl(MakeDialog& dialog, Glib::RefPtr<Session> const& core);
TR_DISABLE_COPY_MOVE(Impl)
private:
void onSourceToggled2(Gtk::ToggleButton* tb, Gtk::FileChooserButton* chooser);
void onChooserChosen(Gtk::FileChooserButton* chooser);
@@ -361,7 +365,7 @@ void MakeDialog::Impl::setFilename(std::string const& filename)
void MakeDialog::Impl::onChooserChosen(Gtk::FileChooserButton* chooser)
{
chooser->set_data(FILE_CHOSEN_KEY, GINT_TO_POINTER(true));
chooser->set_data(FileChosenKey, GINT_TO_POINTER(true));
setFilename(chooser->get_filename());
}
@@ -369,7 +373,7 @@ void MakeDialog::Impl::onSourceToggled2(Gtk::ToggleButton* tb, Gtk::FileChooserB
{
if (tb->get_active())
{
if (chooser->get_data(FILE_CHOSEN_KEY) != nullptr)
if (chooser->get_data(FileChosenKey) != nullptr)
{
onChooserChosen(chooser);
}