clean: fix some issues found by the code analysis of Visual Studio
Some checks failed
SonarCloud / Build and analyze (push) Has been cancelled

This commit is contained in:
shenleban tongying 2024-11-14 07:24:46 -05:00 committed by GitHub
parent 0f71f32ad4
commit c5d682c993
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 40 additions and 34 deletions

View file

@ -492,7 +492,7 @@ struct WebSite
QString id, name, url;
bool enabled;
QString iconFilename;
bool inside_iframe;
bool inside_iframe = false;
WebSite():
enabled( false )
@ -698,7 +698,7 @@ struct Transliteration
struct Lingua
{
bool enable;
bool enable = false;
QString languageCodes;
bool operator==( Lingua const & other ) const
@ -737,13 +737,16 @@ struct Forvo
struct Program
{
bool enabled;
// NOTE: the value of this enum is used for config
enum Type {
Audio,
PlainText,
Html,
PrefixMatch,
MaxTypeValue
} type;
Invalid = -1, // Init value
Audio = 0,
PlainText = 1,
Html = 2,
PrefixMatch = 3,
MaxTypeValue = 4
};
Type type = Invalid;
QString id, name, commandLine;
QString iconFilename;
@ -892,7 +895,7 @@ struct Class
QString articleSavePath; // Path to save articles
bool pinPopupWindow; // Last pin status
bool popupWindowAlwaysOnTop; // Last status of pinned popup window
bool popupWindowAlwaysOnTop = false; // Last status of pinned popup window
QByteArray mainWindowState; // Binary state saved by QMainWindow
QByteArray mainWindowGeometry; // Geometry saved by QMainWindow
@ -929,7 +932,7 @@ struct Class
Group const * getGroup( unsigned id ) const;
//disable tts dictionary. does not need to save to persistent file
bool notts = false;
bool resetState;
bool resetState = false;
};
/// Configuration-specific events. Some parts of the program need to react

View file

@ -45,9 +45,9 @@ DEF_EX( exCorruptedChainData, "Corrupted chain data in the leaf of a btree encou
struct WordArticleLink
{
string word, prefix; // in utf8
uint32_t articleOffset;
uint32_t articleOffset = 0;
WordArticleLink() {}
WordArticleLink() = default;
WordArticleLink( string const & word_, uint32_t articleOffset_, string const & prefix_ = string() ):
word( word_ ),

View file

@ -102,8 +102,7 @@ string convert( string const & in,
}
break;
}
// Fall-through
[[fallthrough]];
default:
inConverted.push_back( i );
afterEol = false;

View file

@ -47,10 +47,11 @@ struct HotkeyStruct
HotkeyStruct() = default;
HotkeyStruct( quint32 key, quint32 key2, quint32 modifier, int handle, int id );
quint32 key, key2;
quint32 modifier;
int handle;
int id;
quint32 key = 0;
quint32 key2 = 0;
quint32 modifier = 0;
int handle = 0;
int id = 0;
#ifdef Q_OS_MAC
EventHotKeyRef hkRef = 0;
EventHotKeyRef hkRef2 = 0;

View file

@ -341,8 +341,11 @@ int main( int argc, char ** argv )
// attach the new console to this application's process
if ( AttachConsole( ATTACH_PARENT_PROCESS ) ) {
// reopen the std I/O streams to redirect I/O to the new console
freopen( "CON", "w", stdout );
freopen( "CON", "w", stderr );
auto ret1 = freopen( "CON", "w", stdout );
auto ret2 = freopen( "CON", "w", stderr );
if ( ret1 == nullptr || ret2 == nullptr ) {
qDebug() << "Attaching console stdout or stderr failed";
}
}
qputenv( "QT_QPA_PLATFORM", "windows:darkmode=1" );

View file

@ -84,13 +84,13 @@ private slots:
private:
virtual bool eventFilter( QObject *, QEvent * );
Config::Class * m_cfg;
QTreeView * m_favoritesTree;
QMenu * m_favoritesMenu;
QAction * m_deleteSelectedAction;
QAction * m_separator;
QAction * m_copySelectedToClipboard;
QAction * m_addFolder;
Config::Class * m_cfg = nullptr;
QTreeView * m_favoritesTree = nullptr;
QMenu * m_favoritesMenu = nullptr;
QAction * m_deleteSelectedAction = nullptr;
QAction * m_separator = nullptr;
QAction * m_copySelectedToClipboard = nullptr;
QAction * m_addFolder = nullptr;
QWidget favoritesPaneTitleBar;
QHBoxLayout favoritesPaneTitleBarLayout;

View file

@ -53,13 +53,13 @@ private slots:
private:
virtual bool eventFilter( QObject *, QEvent * );
Config::Class * m_cfg;
History * m_history;
QListView * m_historyList;
QMenu * m_historyMenu;
QAction * m_deleteSelectedAction;
QAction * m_separator;
QAction * m_copySelectedToClipboard;
Config::Class * m_cfg = nullptr;
History * m_history = nullptr;
QListView * m_historyList = nullptr;
QMenu * m_historyMenu = nullptr;
QAction * m_deleteSelectedAction = nullptr;
QAction * m_separator = nullptr;
QAction * m_copySelectedToClipboard = nullptr;
QWidget historyPaneTitleBar;
QHBoxLayout historyPaneTitleBarLayout;