zlgopen / awtk-mvvm

Model-View-ViewModel for AWTK
GNU Lesser General Public License v2.1
88 stars 27 forks source link

demo13 book名无法显示 #54

Closed Tracker647 closed 5 months ago

Tracker647 commented 5 months ago

自己debug了下看book_create的str_random调用,发现最后到str_set_with_len这里有个str_extend的断言,book->name的extendable属性默认是false的,这样str_extend就返回FAIL,导致后继name无法赋值。

解决方法是加一行:

tk_object_t* book_create(void) {
  tk_object_t* obj = tk_object_create(&s_book_vtable);
  return_value_if_fail(obj != NULL, NULL);

  book_t* book = BOOK(obj);
  book->name.extendable = true; //过str_extend
  str_random(&(book->name), "book %d", 10000);
  book->stock = random() % 100;

  return obj;
}
xianjimli commented 5 months ago

已修改。谢谢

Tracker647 commented 5 months ago

demo39也是书店案例,同样存在name无显示的情况,请修改,谢谢。

xianjimli commented 5 months ago

已修改。谢谢