Skip to content

Codebase: emiting a signal forcedly from outside is a bad practice #540

@asashnov

Description

@asashnov

kiwix-desktop 'master' (830e19b)

Found during working on #454

From src/zimview.cpp:

emit mp_tabBar->currentTitleChanged(str);
emit mp_tabBar->currentZimIdChanged(zimId);
emit mp_tabBar->webActionEnabledChanged(QWebEnginePage::Back, mp_webView->isWebActionEnabled(QWebEnginePage::Back));
emit mp_tabBar->webActionEnabledChanged(QWebEnginePage::Forward, mp_webView->isWebActionEnabled(QWebEnginePage::Forward));
emit mp_library->bookmarksChanged();

According to Qt documentation, this is a bad practice.
By signals, only the object itself should notify that its internal state has changed:

https://doc.qt.io/qt-5/signalsandslots.html

Signals
Signals are emitted by an object when its internal state has changed in some way that might be interesting to the object's client or owner. Signals are public access functions and can be emitted from anywhere, but we recommend to only emit them from the class that defines the signal and its subclasses.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions