Skip to content

Commit

Permalink
clean: fix some issues found by the code analysis of Visual Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
shenlebantongying authored Nov 14, 2024
1 parent 0f71f32 commit c5d682c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 34 deletions.
23 changes: 13 additions & 10 deletions src/config.hh
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ struct WebSite
QString id, name, url;
bool enabled;
QString iconFilename;
bool inside_iframe;
bool inside_iframe = false;

WebSite():
enabled( false )
Expand Down Expand Up @@ -698,7 +698,7 @@ struct Transliteration

struct Lingua
{
bool enable;
bool enable = false;
QString languageCodes;

bool operator==( Lingua const & other ) const
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/dict/btreeidx.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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_ ),
Expand Down
3 changes: 1 addition & 2 deletions src/dict/xdxf2html.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ string convert( string const & in,
}
break;
}
// Fall-through

[[fallthrough]];
default:
inConverted.push_back( i );
afterEol = false;
Expand Down
9 changes: 5 additions & 4 deletions src/hotkeywrapper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down
14 changes: 7 additions & 7 deletions src/ui/favoritespanewidget.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 7 additions & 7 deletions src/ui/historypanewidget.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c5d682c

Please sign in to comment.