Преглед на файлове

Help: Only toggle open/close for SectionNodes

The responsible code was actually casting everything to a SectionNode
pointer, violating type safety all over the place and leading to
frequent crashes. I'm surprised this was not exhibited before; I guess
my recent changes made this bug surface.
kleines Filmröllchen преди 2 години
родител
ревизия
1ec0548158
променени са 1 файла, в които са добавени 3 реда и са изтрити 2 реда
  1. 3 2
      Userland/Applications/Help/ManualModel.cpp

+ 3 - 2
Userland/Applications/Help/ManualModel.cpp

@@ -178,8 +178,9 @@ GUI::Variant ManualModel::data(const GUI::ModelIndex& index, GUI::ModelRole role
 
 void ManualModel::update_section_node_on_toggle(const GUI::ModelIndex& index, bool const open)
 {
-    auto* node = static_cast<Manual::SectionNode*>(index.internal_data());
-    node->set_open(open);
+    auto* node = static_cast<Manual::Node*>(index.internal_data());
+    if (is<Manual::SectionNode>(*node))
+        static_cast<Manual::SectionNode*>(node)->set_open(open);
 }
 
 TriState ManualModel::data_matches(const GUI::ModelIndex& index, const GUI::Variant& term) const