]> Dogcows Code - chaz/tint2/commitdiff
fixed segfault with monitor detection
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Tue, 8 Jun 2010 15:56:04 +0000 (15:56 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Tue, 8 Jun 2010 15:56:04 +0000 (15:56 +0000)
src/config.c
src/server.c

index 61178d11918237301720c7f0843579103923f80f..6233eccc36d8f48d33b903b856265edc01066d2a 100644 (file)
@@ -155,9 +155,7 @@ int get_task_status(char* status)
 
 int config_get_monitor(char* monitor)
 {
-       if (strcmp(monitor, "all") == 0)
-               return -1;
-       else {
+       if (strcmp(monitor, "all") != 0) {
                char* endptr;
                int ret_int = strtol(monitor, &endptr, 10);
                if (*endptr == 0)
@@ -166,6 +164,9 @@ int config_get_monitor(char* monitor)
                        // monitor specified by name, not by index
                        int i, j;
                        for (i=0; i<server.nb_monitor; ++i) {
+                               if (server.monitor[i].names == 0) 
+                                       // xrandr can't identify monitors
+                                       continue;
                                j = 0;
                                while (server.monitor[i].names[j] != 0) {
                                        if (strcmp(monitor, server.monitor[i].names[j++]) == 0)
@@ -174,6 +175,7 @@ int config_get_monitor(char* monitor)
                        }
                }
        }
+       // monitor == "all" or monitor not found or xrandr can't identify monitors
        return -1;
 }
 
index d30b10906ffbb119dc28054ab02e233af8dfd7e5..db50445133a71426af8039df174c7121ba0bc747 100644 (file)
@@ -253,7 +253,7 @@ void get_monitors()
                XineramaScreenInfo *info = XineramaQueryScreens(server.dsp, &nbmonitor);
                XRRScreenResources *res = XRRGetScreenResourcesCurrent(server.dsp, server.root_win);
 
-               if (res->ncrtc >= nbmonitor) {
+               if (res && res->ncrtc >= nbmonitor) {
                        // use xrandr to identify monitors (does not work with proprietery nvidia drivers)
                        printf("xRandr: Found crtc's: %d\n", res->ncrtc );
                        server.monitor = malloc(res->ncrtc * sizeof(Monitor));
@@ -307,7 +307,8 @@ next:
                server.monitor = realloc(server.monitor, server.nb_monitor * sizeof(Monitor));
                qsort(server.monitor, server.nb_monitor, sizeof(Monitor), compareMonitorPos);
 
-               XRRFreeScreenResources(res);
+               if (res)
+                       XRRFreeScreenResources(res);
                XFree(info);
        }
 
This page took 0.025205 seconds and 4 git commands to generate.