@@ -222,9 +222,13 @@ auto GpgKeyTreeModel::create_gpg_key_tree_items(const GpgAbstractKeyPtr &key)
222222 auto i_key = QSharedPointer<GpgKeyTreeItem>::create (key, columns);
223223 i_key->SetEnable (true );
224224 i_key->SetCheckable (checkable_detector_ (i_key->Key ()));
225+ i_key->SetChecked (false );
225226 cached_items_.push_back (i_key);
226227
227228 for (const auto &s_key : g_key->SubKeys ()) {
229+ // avoid bugs due to duplicate key ids
230+ if (g_key->ID () == s_key.ID () || s_key.IsADSK ()) continue ;
231+
228232 QVariantList columns;
229233 columns << " /" ;
230234 columns << (s_key.IsHasCertCap () ? " primary" : " sub" );
@@ -239,6 +243,7 @@ auto GpgKeyTreeModel::create_gpg_key_tree_items(const GpgAbstractKeyPtr &key)
239243 QSharedPointer<GpgSubKey>::create (s_key), columns);
240244 i_s_key->SetEnable (true );
241245 i_s_key->SetCheckable (checkable_detector_ (i_s_key->Key ()));
246+ i_s_key->SetChecked (false );
242247 i_key->AppendChild (i_s_key);
243248 cached_items_.push_back (i_s_key);
244249 }
@@ -254,6 +259,10 @@ auto GpgKeyTreeModel::GetAllCheckedSubKey() -> QContainer<GpgSubKey> {
254259 continue ;
255260 }
256261
262+ LOG_D () << " subkey checked: " << i->Key ()->ID ()
263+ << " uid: " << i->Key ()->UID () << " checkable: " << i->Checkable ()
264+ << " checked: " << i->Checked ();
265+
257266 auto *s_key = dynamic_cast <GpgSubKey *>(i->Key ());
258267 if (s_key == nullptr ) continue ;
259268
@@ -267,6 +276,7 @@ auto GpgKeyTreeModel::GetKeyByIndex(QModelIndex index) -> GpgAbstractKey * {
267276
268277 const auto *item =
269278 static_cast <const GpgKeyTreeItem *>(index.internalPointer ());
279+ assert (item != nullptr );
270280
271281 return item->Key ();
272282}
0 commit comments