]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: Don’t crash when the font is specified after the workspace names in configfil...
authorMichael Stapelberg <michael@stapelberg.de>
Fri, 7 Aug 2009 13:48:13 +0000 (15:48 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Fri, 7 Aug 2009 13:48:13 +0000 (15:48 +0200)
src/config.c
src/workspace.c

index de859564e0cd7277daa2fe5b6d89451a58c4617f..86f0381e6c9ba092af4bd403333bfe5084b91d0d 100644 (file)
@@ -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);
         }
index 1e2aaf4ff9b37d889a36ea830f47b3950be38bf9..e04ea2a9a0ee4ce4e71623d6a913a94ee7f97f15 100644 (file)
@@ -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);
 }