瀏覽代碼

GModel: Have create_index() take a const void*

This is just for convenience really. It lets you skip const_casting in
all the code that calls this API, which you would basically always be
doing otherwise.
Andreas Kling 6 年之前
父節點
當前提交
f6cb2fd2fb
共有 2 個文件被更改,包括 3 次插入3 次删除
  1. 2 2
      Libraries/LibGUI/GModel.cpp
  2. 1 1
      Libraries/LibGUI/GModel.h

+ 2 - 2
Libraries/LibGUI/GModel.cpp

@@ -46,9 +46,9 @@ void GModel::set_selected_index(const GModelIndex& index)
     });
 }
 
-GModelIndex GModel::create_index(int row, int column, void* data) const
+GModelIndex GModel::create_index(int row, int column, const void* data) const
 {
-    return GModelIndex(*this, row, column, data);
+    return GModelIndex(*this, row, column, const_cast<void*>(data));
 }
 
 GModelIndex GModel::sibling(int row, int column, const GModelIndex& parent) const

+ 1 - 1
Libraries/LibGUI/GModel.h

@@ -97,7 +97,7 @@ protected:
     void for_each_view(Function<void(GAbstractView&)>);
     void did_update();
 
-    GModelIndex create_index(int row, int column, void* data = nullptr) const;
+    GModelIndex create_index(int row, int column, const void* data = nullptr) const;
 
 private:
     HashTable<GAbstractView*> m_views;