fix pango crash
This commit is contained in:
		
							parent
							
								
									32c66cee87
								
							
						
					
					
						commit
						8e8e1b7614
					
				| @ -31,10 +31,15 @@ struct Font { | |||||||
| static Font getFont() | static Font getFont() | ||||||
| { | { | ||||||
|     auto fontMap = pango_cairo_font_map_get_default(); |     auto fontMap = pango_cairo_font_map_get_default(); | ||||||
|  |     if (!fontMap) die("pango_cairo_font_map_get_default"); | ||||||
|     auto fontDesc = pango_font_description_from_string(font); |     auto fontDesc = pango_font_description_from_string(font); | ||||||
|  |     if (!fontDesc) die("pango_font_description_from_string"); | ||||||
|     auto tempContext = pango_font_map_create_context(fontMap); |     auto tempContext = pango_font_map_create_context(fontMap); | ||||||
|  |     if (!tempContext) die("pango_font_map_create_context"); | ||||||
|     auto font = pango_font_map_load_font(fontMap, tempContext, fontDesc); |     auto font = pango_font_map_load_font(fontMap, tempContext, fontDesc); | ||||||
|  |     if (!font) die("pango_font_map_load_font"); | ||||||
|     auto metrics = pango_font_get_metrics(font, pango_language_get_default()); |     auto metrics = pango_font_get_metrics(font, pango_language_get_default()); | ||||||
|  |     if (!metrics) die("pango_font_get_metrics"); | ||||||
| 
 | 
 | ||||||
|     auto res = Font {}; |     auto res = Font {}; | ||||||
|     res.description = fontDesc; |     res.description = fontDesc; | ||||||
| @ -43,7 +48,6 @@ static Font getFont() | |||||||
|     pango_font_metrics_unref(metrics); |     pango_font_metrics_unref(metrics); | ||||||
|     g_object_unref(font); |     g_object_unref(font); | ||||||
|     g_object_unref(tempContext); |     g_object_unref(tempContext); | ||||||
|     g_object_unref(fontMap); |  | ||||||
|     return res; |     return res; | ||||||
| } | } | ||||||
| static Font barfont = getFont(); | static Font barfont = getFont(); | ||||||
| @ -68,6 +72,7 @@ Bar::Bar(Monitor *mon) | |||||||
| { | { | ||||||
|     _mon = mon; |     _mon = mon; | ||||||
|     _pangoContext.reset(pango_font_map_create_context(pango_cairo_font_map_get_default())); |     _pangoContext.reset(pango_font_map_create_context(pango_cairo_font_map_get_default())); | ||||||
|  |     if (!_pangoContext) die("pango_font_map_create_context"); | ||||||
|     for (auto i=0u; i<tagNames.size(); i++) { |     for (auto i=0u; i<tagNames.size(); i++) { | ||||||
|         _tags.push_back({ ZNET_TAPESOFTWARE_DWL_WM_MONITOR_V1_TAG_STATE_NONE, 0, 0, createComponent(tagNames[i]) }); |         _tags.push_back({ ZNET_TAPESOFTWARE_DWL_WM_MONITOR_V1_TAG_STATE_NONE, 0, 0, createComponent(tagNames[i]) }); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -47,6 +47,7 @@ void setlayout(Monitor &m, const Arg &arg); | |||||||
| void tag(Monitor &m, const Arg &arg); | void tag(Monitor &m, const Arg &arg); | ||||||
| void toggletag(Monitor &m, const Arg &arg); | void toggletag(Monitor &m, const Arg &arg); | ||||||
| void spawn(Monitor&, const Arg &arg); | void spawn(Monitor&, const Arg &arg); | ||||||
|  | [[noreturn]] void die(const char *why); | ||||||
| 
 | 
 | ||||||
| // wayland smart pointers
 | // wayland smart pointers
 | ||||||
| template<typename T> | template<typename T> | ||||||
|  | |||||||
| @ -55,7 +55,6 @@ static void cleanup(); | |||||||
| static void requireGlobal(const void *p, const char *name); | static void requireGlobal(const void *p, const char *name); | ||||||
| static void waylandFlush(); | static void waylandFlush(); | ||||||
| [[noreturn]] static void diesys(const char *why); | [[noreturn]] static void diesys(const char *why); | ||||||
| [[noreturn]] static void die(const char *why); |  | ||||||
| 
 | 
 | ||||||
| wl_display *display; | wl_display *display; | ||||||
| wl_compositor *compositor; | wl_compositor *compositor; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user