[cairo-bugs] [Bug 53121] New: My program runs successfully with Cairo-1.10.2, but getting SIGSEGV with 1.12.2.
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Sat Aug 4 07:08:28 PDT 2012
https://bugs.freedesktop.org/show_bug.cgi?id=53121
Bug #: 53121
Summary: My program runs successfully with Cairo-1.10.2, but
getting SIGSEGV with 1.12.2.
Classification: Unclassified
Product: cairo
Version: 1.12.2
Platform: x86 (IA32)
OS/Version: Windows (All)
Status: NEW
Severity: blocker
Priority: medium
Component: win32 backend
AssignedTo: cairo-bugs at cairographics.org
ReportedBy: dogusanh at tr.net
QAContact: cairo-bugs at cairographics.org
My environment: (WinXP, MinGW (gcc-4.6.2), Cairo-1.12.2, Pixman-0.26.0)
Test program follows:
#include <windows.h>
#include <math.h>
#include <cairo.h>
//#if CAIRO_HAS_XLIB_SURFACE
// #include <X11/Xlib.h>
// #include <gtk/gtk.h>
// #include <gdk/gdk.h>
//#endif
#if CAIRO_HAS_SVG_SURFACE
#include <cairo-svg.h>
#endif
#if CAIRO_HAS_PDF_SURFACE
#include <cairo-pdf.h>
#endif
#if CAIRO_HAS_PS_SURFACE
#include <cairo-ps.h>
#endif
#if CAIRO_HAS_XCB_SURFACE
#include <cairo-xcb.h>
#endif
#if CAIRO_HAS_XLIB_SURFACE
#include <cairo-xlib.h>
#endif
#if CAIRO_HAS_WIN32_SURFACE
#include <cairo-win32.h>
#endif
#if CAIRO_HAS_BEOS_SURFACE
#include <cairo-beos.h>
#endif
#if CAIRO_HAS_DIRECTFB_SURFACE
#include <cairo-directfb.h>
#endif
#if CAIRO_HAS_OS2_SURFACE
#include <cairo-os2.h>
#endif
#if CAIRO_HAS_GLITZ_SURFACE
#include <cairo-glitz.h>
#endif
#if CAIRO_HAS_QUARTZ_SURFACE
#include <cairo-quartz.h>
#endif
#if CAIRO_HAS_ATSUI_FONT
#include <cairo-atsui.h>
#endif
#if CAIRO_HAS_FT_FONT
#include <cairo-ft.h>
#endif
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
const wchar_t* szClassName = L"CairoTest";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by
windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the
window class */
wincl.cbWndExtra = 0; /* structure or the window
instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
L"CairoTest", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
static void
snap_point (cairo_t *cr, double *x, double *y, bool odd_integer_line_width =
true)
{
cairo_user_to_device (cr, x, y);
if (odd_integer_line_width)
{
// round to nearest half integer
*x = round (*x) + .5;
*y = round (*y) + .5;
}
else
{
// round to nearest integer
*x = round (*x);
*y = round (*y);
}
cairo_device_to_user (cr, x, y);
}
static double
snapx(cairo_t* cr, double ax)
{
double x = ax;
double y = 0;
snap_point(cr, &x, &y);
return x;
}
static double
snapy(cairo_t* cr, double ay)
{
double x = 0;
double y = ay;
snap_point(cr, &x, &y);
return y;
}
static void
draw_grid_lines(cairo_t* cr, int maxx, int maxy, int step, double linewidth)
{
for (int x = 0; x < maxx; x += step)
{
cairo_move_to (cr, snapx(cr,x), snapy(cr,0));
cairo_line_to (cr, snapx(cr,x), snapy(cr,maxy));
cairo_close_path(cr);
}
for (int y = 0; y < maxy; y += step)
{
cairo_move_to (cr, snapx(cr,0), snapy(cr,y));
cairo_line_to (cr, snapx(cr,maxx), snapy(cr,y));
cairo_close_path(cr);
}
//cairo_set_source_rgb(cr, 0.84, 0.84, 0.84); //paper color: Dim Grey
cairo_set_source_rgb(cr, 0.64, 0.64, 0.64); //?
cairo_save(cr);
{
cairo_identity_matrix (cr);
cairo_set_line_width (cr, linewidth);
cairo_stroke (cr);
}
cairo_restore(cr);
}
static void
draw_grid(cairo_t* cr, int pw, int ph, int zoom)
{
cairo_save(cr);
{
// line positions in mm
if (0 < zoom && zoom <= 100)
{
draw_grid_lines(cr, pw, ph, 1000, .2);
}
else if (100 < zoom && zoom <= 250)
{
draw_grid_lines(cr, pw, ph, 1000, .2);
}
else if (250 < zoom)
{
draw_grid_lines(cr, pw, ph, 500, .2);
draw_grid_lines(cr, pw, ph, 1000, .4);
}
}
cairo_restore(cr);
}
static void
draw_paper(cairo_t* cr, double sf, int pw, int ph)
{
double shadow = 3.0 / sf;
cairo_save(cr);
{
cairo_rectangle (cr, shadow, shadow, pw, ph);
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
cairo_fill(cr);
cairo_rectangle (cr, 0, 0, pw, ph);
cairo_set_source_rgb(cr, 0.84, 0.84, 0.84); //Dim Grey
cairo_fill(cr);
}
cairo_restore(cr);
}
PAINTSTRUCT ps;
HDC hdc;
void dopainting(HDC hdc)
{
cairo_t *cr = cairo_create(cairo_win32_surface_create( hdc ));
// dark gray background
cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
cairo_paint(cr);
draw_paper(cr, 1.0, 500, 500);
draw_grid(cr, 500, 500, 100);
cairo_destroy(cr);
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue
*/
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
dopainting(hdc);
EndPaint(hwnd, &ps);
ValidateRect(hwnd, NULL);
break;
default: /* for messages that we don't deal with
*/
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
}
--
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA Contact for the bug.
You are the assignee for the bug.
More information about the cairo-bugs
mailing list