Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

Commit 50fef53

Browse files
committed
fix: error when page has no title
1 parent f3c9d22 commit 50fef53

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/ui/views/browser.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ typedef struct BrowserViewRec_ {
2525

2626
static LCUI_WidgetPrototype browser_proto;
2727

28-
static void BrowserView_OnBtnAddTabClick(LCUI_Widget w, LCUI_WidgetEvent e, void *arg)
28+
static void BrowserView_OnBtnAddTabClick(LCUI_Widget w, LCUI_WidgetEvent e,
29+
void *arg)
2930
{
3031
BrowserView_Active(e->data, BrowserView_Load(e->data, "/"));
3132
}
@@ -46,7 +47,8 @@ static void BrowserView_OnInit(LCUI_Widget w)
4647
Widget_AddClass(self->tabbar, "v-browser__tabbar");
4748
Widget_Append(self->tabbar, self->btn_add);
4849
Widget_Append(w, self->tabbar);
49-
Widget_BindEvent(self->btn_add, "click", BrowserView_OnBtnAddTabClick, w, NULL);
50+
Widget_BindEvent(self->btn_add, "click", BrowserView_OnBtnAddTabClick,
51+
w, NULL);
5052
}
5153

5254
static void BrowserView_OnDestroy(LCUI_Widget w)
@@ -92,7 +94,11 @@ static void BrowserView_OnPageLoaded(LCUI_Widget w, LCUI_WidgetEvent e,
9294
page = e->data;
9395
page->title[255] = 0;
9496
page->loading = FALSE;
95-
wcsncpy(page->title, e->target->title, 255);
97+
if (e->target->title) {
98+
wcsncpy(page->title, e->target->title, 255);
99+
} else {
100+
wcscpy(page->title, L"Untitled Page");
101+
}
96102
FrameTab_SetLoading(page->tab, page->loading);
97103
FrameTab_SetTextW(page->tab, page->title);
98104
}

0 commit comments

Comments
 (0)