summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-04-04 15:23:18 +0200
committerMattias Andrée <maandree@operamail.com>2014-04-04 15:23:31 +0200
commit858e273164bd1e4675c591b0f561c0855949d5dd (patch)
tree1855ba200183d38821798036f575068b35006ca0
parentmulti-display support can apply once, then it segfaults (diff)
downloadblueshift-858e273164bd1e4675c591b0f561c0855949d5dd.tar.gz
blueshift-858e273164bd1e4675c591b0f561c0855949d5dd.tar.bz2
blueshift-858e273164bd1e4675c591b0f561c0855949d5dd.tar.xz
fix double free error and sigfault error in multi-display support
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r--TODO1
-rw-r--r--examples/comprehensive12
-rw-r--r--src/blueshift_randr.pyx11
-rw-r--r--src/blueshift_vidmode.pyx12
4 files changed, 18 insertions, 18 deletions
diff --git a/TODO b/TODO
index c618ad1..70a81f2 100644
--- a/TODO
+++ b/TODO
@@ -2,7 +2,6 @@ High priority:
Add support for monitor hotplugging
Add models for calculating fade and refresh rate parameters
Test with multiple X screens
- Fix multi-display support
Medium priority:
Add a section in manual for information on which order
diff --git a/examples/comprehensive b/examples/comprehensive
index 41b0137..dcde526 100644
--- a/examples/comprehensive
+++ b/examples/comprehensive
@@ -90,8 +90,8 @@ download_command = None
# Method for applying colour curves in X.
-apply_curves_x = randr
-#apply_curves_x = vidmode
+#apply_curves_x = randr
+apply_curves_x = vidmode
# Method for applying colour curves in TTY.
apply_curves_tty_ = drm
@@ -131,7 +131,7 @@ def apply_curves(*crtcs, screen = 0):
@param screen:int The screen to which the monitors belong
'''
# Single display and single server, variant:
- #(apply_curves_tty if ttymode apply_curves_x)(*crtcs, screen = screen)
+ (apply_curves_tty if ttymode apply_curves_x)(*crtcs, screen = screen)
# Variant for TTY and all X display:
#apply_curves_tty(*crtcs, screen = screen)
@@ -144,9 +144,9 @@ def apply_curves(*crtcs, screen = 0):
# pass
# Variant for TTY and selected X displays:
- apply_curves_tty(*crtcs, screen = screen)
- for display in [None, ':1']: # Current and :1
- apply_curves_x(*crtcs, screen = screen, display = display)
+ #apply_curves_tty(*crtcs, screen = screen)
+ #for display in [None, ':1']: # Current and :1
+ # apply_curves_x(*crtcs, screen = screen, display = display)
# Keep uncomment to use solar position.
diff --git a/src/blueshift_randr.pyx b/src/blueshift_randr.pyx
index e845f65..80caab1 100644
--- a/src/blueshift_randr.pyx
+++ b/src/blueshift_randr.pyx
@@ -32,11 +32,6 @@ cdef extern void blueshift_randr_close()
cdef unsigned short int* r_c
cdef unsigned short int* g_c
cdef unsigned short int* b_c
-r_c = <unsigned short int*>malloc(256 * 2)
-g_c = <unsigned short int*>malloc(256 * 2)
-b_c = <unsigned short int*>malloc(256 * 2)
-if (r_c is NULL) or (g_c is NULL) or (b_c is NULL):
- raise MemoryError()
@@ -48,9 +43,15 @@ def randr_open(int use_screen, display):
@param display:bytes? The display to use, `None` for the current
@return :int Zero on success
'''
+ global r_c, g_c, b_c
cdef char* display_ = NULL
if display is not None:
display_ = display
+ r_c = <unsigned short int*>malloc(256 * 2)
+ g_c = <unsigned short int*>malloc(256 * 2)
+ b_c = <unsigned short int*>malloc(256 * 2)
+ if (r_c is NULL) or (g_c is NULL) or (b_c is NULL):
+ raise MemoryError()
return blueshift_randr_open(use_screen, display_)
diff --git a/src/blueshift_vidmode.pyx b/src/blueshift_vidmode.pyx
index 7ad7a4c..c591db5 100644
--- a/src/blueshift_vidmode.pyx
+++ b/src/blueshift_vidmode.pyx
@@ -38,11 +38,6 @@ vidmode_gamma_size = 0
cdef unsigned short int* r_c
cdef unsigned short int* g_c
cdef unsigned short int* b_c
-r_c = <unsigned short int*>malloc(256 * 2)
-g_c = <unsigned short int*>malloc(256 * 2)
-b_c = <unsigned short int*>malloc(256 * 2)
-if (r_c is NULL) or (g_c is NULL) or (b_c is NULL):
- raise MemoryError()
@@ -54,10 +49,15 @@ def vidmode_open(int use_screen, display):
@param display:bytes? The display to use, `None` for the current
@return :bool Whether call was successful
'''
- global vidmode_gamma_size
+ global vidmode_gamma_size, r_c, g_c, b_c
cdef char* display_ = NULL
if display is not None:
display_ = display
+ r_c = <unsigned short int*>malloc(256 * 2)
+ g_c = <unsigned short int*>malloc(256 * 2)
+ b_c = <unsigned short int*>malloc(256 * 2)
+ if (r_c is NULL) or (g_c is NULL) or (b_c is NULL):
+ raise MemoryError()
vidmode_gamma_size = blueshift_vidmode_open(use_screen, display_)
return vidmode_gamma_size > 1