From 6192975a041eaacb267ddabc0c2dcb4f33e3b58b Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 7 Aug 2009 15:48:13 +0200 Subject: [PATCH] =?utf8?q?Bugfix:=20Don=E2=80=99t=20crash=20when=20the=20f?= =?utf8?q?ont=20is=20specified=20after=20the=20workspace=20names=20in=20co?= =?utf8?q?nfigfile=20(Thanks=20xiaodong)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/config.c | 9 ++++++++- src/workspace.c | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/config.c b/src/config.c index de859564..86f0381e 100644 --- a/src/config.c +++ b/src/config.c @@ -485,8 +485,15 @@ void load_configuration(xcb_connection_t *conn, const char *override_configpath, /* Set an empty name for every workspace which got no name */ for (int i = 0; i < 10; i++) { - if (workspaces[i].name != NULL) + Workspace *ws = &(workspaces[i]); + if (ws->name != NULL) { + /* If the font was not specified when the workspace name + * was loaded, we need to predict the text width now */ + if (ws->text_width == 0) + ws->text_width = predict_text_width(global_conn, + config.font, ws->name, ws->name_len); continue; + } workspace_set_name(&(workspaces[i]), NULL); } diff --git a/src/workspace.c b/src/workspace.c index 1e2aaf4f..e04ea2a9 100644 --- a/src/workspace.c +++ b/src/workspace.c @@ -41,7 +41,9 @@ void workspace_set_name(Workspace *ws, const char *name) { FREE(ws->name); ws->name = convert_utf8_to_ucs2(label, &(ws->name_len)); - ws->text_width = predict_text_width(global_conn, config.font, ws->name, ws->name_len); + if (config.font != NULL) + ws->text_width = predict_text_width(global_conn, config.font, ws->name, ws->name_len); + else ws->text_width = 0; free(label); } -- 2.39.5