-
Notifications
You must be signed in to change notification settings - Fork 55
fix: sometimes dock might be empty after boot and login #1260
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ namespace apps | |
| AMAppItemModel::AMAppItemModel(QObject *parent) | ||
| : AppItemModel(parent) | ||
| , m_manager(new ObjectManager("org.desktopspec.ApplicationManager1", "/org/desktopspec/ApplicationManager1", QDBusConnection::sessionBus())) | ||
| , m_ready(false) | ||
| { | ||
| qRegisterMetaType<ObjectInterfaceMap>(); | ||
| qDBusRegisterMetaType<ObjectInterfaceMap>(); | ||
|
|
@@ -60,9 +61,17 @@ AMAppItemModel::AMAppItemModel(QObject *parent) | |
| appendRow(c); | ||
| } | ||
| } | ||
|
|
||
| setProperty("ready", true); | ||
| qCDebug(appsLog) << "AMAppItemModel is now ready with apps counts:" << rowCount(); | ||
|
Comment on lines
+65
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (bug_risk): Directly setting the 'ready' property may bypass signal emission. Use a setter for 'm_ready' that emits 'readyChanged' to ensure listeners are notified of state changes. Suggested implementation: setReady(true);
qCDebug(appsLog) << "AMAppItemModel is now ready with apps counts:" << rowCount();
void AMAppItemModel::setReady(bool ready)
{
if (m_ready == ready)
return;
m_ready = ready;
emit readyChanged(m_ready);
}
bool AMAppItemModel::ready() const
{
return m_ready;
You must ensure that:
|
||
| }); | ||
| } | ||
|
|
||
| bool AMAppItemModel::ready() const | ||
| { | ||
| return m_ready; | ||
| } | ||
|
|
||
| AMAppItem * AMAppItemModel::appItem(const QString &id) | ||
| { | ||
| for (int i = 0; i < rowCount(); i++) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,13 +13,19 @@ class AMAppItem; | |
| class AMAppItemModel : public AppItemModel | ||
| { | ||
| Q_OBJECT | ||
|
|
||
| Q_PROPERTY(bool ready MEMBER m_ready READ ready NOTIFY readyChanged) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Using MEMBER in Q_PROPERTY with custom signal may not emit signal automatically. To ensure 'readyChanged' is emitted when 'm_ready' changes, update 'm_ready' only via a setter that emits the signal. Suggested implementation: Q_PROPERTY(bool ready READ ready WRITE setReady NOTIFY readyChanged)signals:
void readyChanged(bool);
public:
void setReady(bool ready);
private:
bool m_ready;You must implement the void AMAppItemModel::setReady(bool ready) Also, ensure all updates to |
||
| public: | ||
| explicit AMAppItemModel(QObject *parent = nullptr); | ||
|
|
||
| AMAppItem * appItem(const QString &id); | ||
|
|
||
| bool ready() const; | ||
|
|
||
| signals: | ||
| void readyChanged(bool); | ||
|
|
||
| private: | ||
| bool m_ready; | ||
| ObjectManager *m_manager; | ||
| }; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种行为,有没有model提供的机制呀,初始化的时候,是初始化里面的数据,能使用beginResetModel这种么,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以用reset,相当于要改model初始化那边填入数据时的形式,暂时没排查有没有别的影响。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QStandardItemModel 没提供比较方便的 reset 的方式,加上暂时未排查是否有别的影响,暂时不改为完全依赖 reset 状态来载入任务栏驻留状态的写法。