Code Cleanup - Member variables not initialized in GdiEngine's constructor #1203

Open
opened 2026-01-30 22:19:01 +00:00 by claunia · 1 comment
Owner

Originally created by @dlong11 on GitHub (May 18, 2019).

Minor Code cleanup

In src/renderer/gdi/state.cpp
GdiEngine's constructor is not initializing all of it's member variables.

_isTrueTypeFont
_fontCodepage
_tmFontMetrics
_coordFontLast
_psInvalidData

In Debug only
_debugWindow
_debugContext

As far as I can tell, none of the above variables are used before being initialized (in the normal code path). Most of these get set in UpdateFont and _CreateDebugWindow. It might make sense to make a pass and initialize these in the header with default values. Some members are correctly being set to a default value in the constructor, but it might be better for maintainability to remove those and initialize them in the header also.

Originally created by @dlong11 on GitHub (May 18, 2019). Minor Code cleanup In src/renderer/gdi/state.cpp GdiEngine's constructor is not initializing all of it's member variables. _isTrueTypeFont _fontCodepage _tmFontMetrics _coordFontLast _psInvalidData In Debug only _debugWindow _debugContext As far as I can tell, none of the above variables are used before being initialized (in the normal code path). Most of these get set in UpdateFont and _CreateDebugWindow. It might make sense to make a pass and initialize these in the header with default values. Some members are correctly being set to a default value in the constructor, but it might be better for maintainability to remove those and initialize them in the header also.
claunia added the Product-ConhostIssue-BugArea-Build labels 2026-01-30 22:19:01 +00:00
Author
Owner

@binarycrusader commented on GitHub (May 18, 2019):

Spot-checked a few, so marking as confirmed.

Two important guidelines to keep in mind for whomever wishes to resolve this:

C.48: Prefer in-class initializers to member initializers in constructors for constant initializers
C.45: Don’t define a default constructor that only initializes data members; use in-class member initializers instead

@binarycrusader commented on GitHub (May 18, 2019): Spot-checked a few, so marking as confirmed. Two important guidelines to keep in mind for whomever wishes to resolve this: [C.48: Prefer in-class initializers to member initializers in constructors for constant initializers](http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c48-prefer-in-class-initializers-to-member-initializers-in-constructors-for-constant-initializers) [C.45: Don’t define a default constructor that only initializes data members; use in-class member initializers instead](http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c45-dont-define-a-default-constructor-that-only-initializes-data-members-use-in-class-member-initializers-instead)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1203