Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: unsingletonize Resources/Resources2 #5460

Merged
merged 2 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Dev: Refactor `TwitchIrcServer`, making it abstracted. (#5421, #5435)
- Dev: Reduced the amount of scale events. (#5404, #5406)
- Dev: Removed unused timegate settings. (#5361)
- Dev: Unsingletonize `Resources2`. (#5460)
- Dev: All Lua globals now show in the `c2` global in the LuaLS metadata. (#5385)
- Dev: Images are now loaded in worker threads. (#5431)
- Dev: Qt Creator now auto-configures Conan when loading the project and skips vcpkg. (#5305)
Expand Down
5 changes: 2 additions & 3 deletions cmake/resources/ResourcesAutogen.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include <QPixmap>
#include "common/Singleton.hpp"

namespace chatterino {

class Resources2 : public Singleton
class Resources2
{
public:
Resources2();

@RES_HEADER_CONTENT@
};
} // namespace chatterino
} // namespace chatterino
11 changes: 8 additions & 3 deletions src/singletons/Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

#include "debug/AssertInGuiThread.hpp"

namespace chatterino {
namespace {
static Resources2 *resources = nullptr;
}

using namespace chatterino;

static Resources2 *resources = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'resources' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]

Suggested change
static Resources2 *resources = nullptr;
Resources2 *resources = nullptr;

Copy link
Contributor

Choose a reason for hiding this comment

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

warning: invalid case style for global variable 'resources' [readability-identifier-naming]

Suggested change
static Resources2 *resources = nullptr;
static Resources2 *RESOURCES = nullptr;

src/singletons/Resources.cpp:16:

-     assert(resources);
+     assert(RESOURCES);

src/singletons/Resources.cpp:18:

-     return *resources;
+     return *RESOURCES;

src/singletons/Resources.cpp:25:

-     resources = new Resources2;
+     RESOURCES = new Resources2;

Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'resources' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

static Resources2 *resources = nullptr;
                   ^

Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'resources' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]

static Resources2 *resources = nullptr;
                   ^

Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'resources' is a static definition in anonymous namespace; static is redundant here [readability-static-definition-in-anonymous-namespace]

Suggested change
static Resources2 *resources = nullptr;
Resources2 *resources = nullptr;

Copy link
Contributor

Choose a reason for hiding this comment

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

warning: invalid case style for global variable 'resources' [readability-identifier-naming]

Suggested change
static Resources2 *resources = nullptr;
static Resources2 *RESOURCES = nullptr;

src/singletons/Resources.cpp:16:

-     assert(resources);
+     assert(RESOURCES);

src/singletons/Resources.cpp:18:

-     return *resources;
+     return *RESOURCES;

src/singletons/Resources.cpp:25:

-     resources = new Resources2;
+     RESOURCES = new Resources2;

Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'resources' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]

static Resources2 *resources = nullptr;
                   ^

Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable 'resources' provides global access to a non-const object; consider making the pointed-to data 'const' [cppcoreguidelines-avoid-non-const-global-variables]

static Resources2 *resources = nullptr;
                   ^


} // namespace

namespace chatterino {

Resources2 &getResources()
{
Expand Down
Loading