Skip to content

Commit

Permalink
Fix nvidia crash (resolves #520). (#698)
Browse files Browse the repository at this point in the history
* Fix XShape handling.
 * Fix crash when XDamage is disabled.
 * Make sure the nvidia COOLER target is available before trying to pull
 attribute values.
 * Check the nvidia extension is actually available.
 * Check that the display is valid.
  • Loading branch information
brndnmtthws authored Dec 10, 2018
1 parent 155563a commit a0d4393
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 89 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ RUN sh -c 'if [ "$X11" = "yes" ] ; then \
libcurl4-gnutls-dev \
libsystemd-dev \
libxml2-dev \
libxnvctrl-dev \
tolua++ \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /conky
Expand Down
51 changes: 17 additions & 34 deletions src/conky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@
#ifdef BUILD_IMLIB2
#include "imlib2.h"
#endif /* BUILD_IMLIB2 */
#ifdef BUILD_XSHAPE
#include <X11/extensions/shape.h>
#endif /* BUILD_XSHAPE */
#endif /* BUILD_X11 */
#ifdef BUILD_NCURSES
#include <ncurses.h>
Expand Down Expand Up @@ -2016,26 +2013,6 @@ static void main_loop() {
sigaddset(&newmask, SIGUSR1);
#endif

#ifdef BUILD_X11
#ifdef BUILD_XSHAPE
if (out_to_x.get(*state)) {
/* allow only decorated windows to be given mouse input */
int major_version, minor_version;
if (XShapeQueryVersion(display, &major_version, &minor_version) == 0) {
NORM_ERR("Input shapes are not supported");
} else {
if (own_window.get(*state) &&
(own_window_type.get(*state) != TYPE_NORMAL ||
((TEST_HINT(own_window_hints.get(*state), HINT_UNDECORATED)) !=
0))) {
XShapeCombineRectangles(display, window.window, ShapeInput, 0, 0,
nullptr, 0, ShapeSet, Unsorted);
}
}
}
#endif /* BUILD_XSHAPE */
#endif /* BUILD_X11 */

last_update_time = 0.0;
next_update_time = get_time() - fmod(get_time(), active_update_interval());
info.looped = 0;
Expand All @@ -2055,8 +2032,6 @@ static void main_loop() {

#ifdef BUILD_X11
if (out_to_x.get(*state)) {
XFlush(display);

/* wait for X event or timeout */

if (XPending(display) == 0) {
Expand Down Expand Up @@ -2210,6 +2185,7 @@ static void main_loop() {
r.width = ev.xexpose.width;
r.height = ev.xexpose.height;
XUnionRectWithRegion(&r, x11_stuff.region, x11_stuff.region);
XSync(display, False);
break;
}

Expand Down Expand Up @@ -2339,8 +2315,10 @@ static void main_loop() {
}

#ifdef BUILD_XDAMAGE
XDamageSubtract(display, x11_stuff.damage, x11_stuff.region2, None);
XFixesSetRegion(display, x11_stuff.region2, nullptr, 0);
if (x11_stuff.damage) {
XDamageSubtract(display, x11_stuff.damage, x11_stuff.region2, None);
XFixesSetRegion(display, x11_stuff.region2, nullptr, 0);
}
#endif /* BUILD_XDAMAGE */

/* XDBE doesn't seem to provide a way to clear the back buffer
Expand Down Expand Up @@ -2433,9 +2411,11 @@ static void main_loop() {
XDestroyRegion(x11_stuff.region);
x11_stuff.region = nullptr;
#ifdef BUILD_XDAMAGE
XDamageDestroy(display, x11_stuff.damage);
XFixesDestroyRegion(display, x11_stuff.region2);
XFixesDestroyRegion(display, x11_stuff.part);
if (x11_stuff.damage) {
XDamageDestroy(display, x11_stuff.damage);
XFixesDestroyRegion(display, x11_stuff.region2);
XFixesDestroyRegion(display, x11_stuff.part);
}
#endif /* BUILD_XDAMAGE */
}
#endif /* BUILD_X11 */
Expand Down Expand Up @@ -2654,11 +2634,14 @@ static void X11_create_window() {
if (XDamageQueryExtension(display, &x11_stuff.event_base,
&x11_stuff.error_base) == 0) {
NORM_ERR("Xdamage extension unavailable");
x11_stuff.damage = 0;
} else {
x11_stuff.damage =
XDamageCreate(display, window.window, XDamageReportNonEmpty);
x11_stuff.region2 =
XFixesCreateRegionFromWindow(display, window.window, 0);
x11_stuff.part = XFixesCreateRegionFromWindow(display, window.window, 0);
}
x11_stuff.damage =
XDamageCreate(display, window.window, XDamageReportNonEmpty);
x11_stuff.region2 = XFixesCreateRegionFromWindow(display, window.window, 0);
x11_stuff.part = XFixesCreateRegionFromWindow(display, window.window, 0);
#endif /* BUILD_XDAMAGE */

selected_font = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/fonts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void set_font() {
}

void setup_fonts() {
DBGP("setting up fonts");
DBGP2("setting up fonts");
if (!out_to_x.get(*state)) { return; }
#ifdef BUILD_XFT
if (use_xft.get(*state)) {
Expand Down Expand Up @@ -146,7 +146,7 @@ void free_fonts(bool utf8) {
}

void load_fonts(bool utf8) {
DBGP("loading fonts");
DBGP2("loading fonts");
if (!out_to_x.get(*state)) { return; }
for (auto &font : fonts) {
#ifdef BUILD_XFT
Expand Down
Loading

0 comments on commit a0d4393

Please sign in to comment.