Fix 'nvidia with ncurses segfaults' (sf.net #3006233)
[monky] / src / conky.c
index a289172..3144172 100644 (file)
@@ -2300,7 +2300,7 @@ void generate_text_internal(char *p, int p_max_size,
                        }
 #ifdef NVIDIA
                        OBJ(nvidia) {
-                               print_nvidia_value(obj, display, p, p_max_size);
+                               print_nvidia_value(obj, p, p_max_size);
                        }
 #endif /* NVIDIA */
 #ifdef APCUPSD
@@ -2380,7 +2380,14 @@ void generate_text_internal(char *p, int p_max_size,
 #ifdef HAVE_ICONV
                        iconv_convert(&a, buff_in, p, p_max_size);
 #endif /* HAVE_ICONV */
-                       substitute_newlines(p, a - 2);
+                       if (obj->type == OBJ_execp || obj->type == OBJ_execpi || obj->type
+                                       == OBJ_exec
+#ifdef HAVE_LUA
+                                       || obj->type == OBJ_lua || obj->type == OBJ_lua_parse
+#endif /* HAVE_LUA */
+                                       ) {
+                               substitute_newlines(p, a - 2);
+                       }
                        p += a;
                        p_max_size -= a;
                        (*p) = 0;
@@ -3987,7 +3994,8 @@ static void reload_config(void)
 }
 
 #ifdef X11
-void clean_up_x11() {
+void clean_up_x11(void)
+{
        if(window_created == 1) {
                XClearArea(display, window.window, text_start_x - window.border_inner_margin - window.border_outer_margin - window.border_width,
                        text_start_y - window.border_inner_margin - window.border_outer_margin - window.border_width,
@@ -4047,6 +4055,9 @@ void clean_up_without_threads(void *memtofree1, void* memtofree2) {
                font_count = -1;
        }
 
+#ifdef NVIDIA
+       set_nvidia_display(NULL);
+#endif
 #endif /* X11 */
 
        free_templates();
@@ -4594,6 +4605,12 @@ char load_config_file(const char *f)
                                disp = strdup(value);
                        }
                }
+#ifdef NVIDIA
+               CONF("nvidia_display") {
+                       if(value)
+                               set_nvidia_display(value);
+               }
+#endif
                CONF("alignment") {
                        setalignment(&text_alignment, window.type, value, f, line, 1);
                }