Bug 380464 - "crashed [@ gfxPlatformGtk::SetSurfaceGdkWindow] in case where I used to see
bug 263160" [p=vlad r=stuart a=blocking1.9+]
--- a/gfx/thebes/public/gfxPlatformGtk.h
+++ b/gfx/thebes/public/gfxPlatformGtk.h
@@ -52,21 +52,16 @@ public:
static gfxPlatformGtk *GetPlatform() {
return (gfxPlatformGtk*) gfxPlatform::GetPlatform();
}
already_AddRefed<gfxASurface> CreateOffscreenSurface(const gfxIntSize& size,
gfxASurface::gfxImageFormat imageFormat);
- GdkDrawable *GetSurfaceGdkDrawable(gfxASurface *aSurf);
-
- void SetSurfaceGdkWindow(gfxASurface *aSurf,
- GdkWindow *win);
-
nsresult GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
nsStringArray& aListOfFonts);
nsresult UpdateFontList();
nsresult ResolveFontName(const nsAString& aFontName,
FontResolverCallback aCallback,
--- a/gfx/thebes/src/gfxPlatformGtk.cpp
+++ b/gfx/thebes/src/gfxPlatformGtk.cpp
@@ -64,24 +64,16 @@
#include "nsMathUtils.h"
#include "lcms.h"
PRInt32 gfxPlatformGtk::sDPI = -1;
gfxFontconfigUtils *gfxPlatformGtk::sFontconfigUtils = nsnull;
-static cairo_user_data_key_t cairo_gdk_window_key;
-static cairo_user_data_key_t cairo_gdk_pixmap_key;
-static void do_gdk_pixmap_unref (void *data)
-{
- GdkPixmap *pmap = (GdkPixmap*)data;
- gdk_pixmap_unref (pmap);
-}
-
gfxPlatformGtk::gfxPlatformGtk()
{
#ifdef MOZ_ENABLE_GLITZ
if (UseGlitz())
glitz_glx_init(NULL);
#endif
if (!sFontconfigUtils)
sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
@@ -169,24 +161,16 @@ gfxPlatformGtk::CreateOffscreenSurface(c
gdk_drawable_set_colormap(GDK_DRAWABLE(pixmap), nsnull);
newSurface = new gfxXlibSurface(display,
GDK_PIXMAP_XID(GDK_DRAWABLE(pixmap)),
xrenderFormat,
size);
}
- if (pixmap && newSurface) {
- // set up the surface to auto-unref the gdk pixmap when the surface
- // is released
- newSurface->SetData(&cairo_gdk_pixmap_key,
- pixmap,
- do_gdk_pixmap_unref);
- }
-
} else {
#ifdef MOZ_ENABLE_GLITZ
glitz_drawable_format_t *gdformat = glitz_glx_find_pbuffer_format
(display,
gdk_x11_get_default_screen(),
0, NULL, 0);
glitz_drawable_t *gdraw =
@@ -210,41 +194,16 @@ gfxPlatformGtk::CreateOffscreenSurface(c
newSurface = new gfxGlitzSurface(gdraw, gsurf, PR_TRUE);
#endif
}
NS_IF_ADDREF(newSurface);
return newSurface;
}
-GdkDrawable*
-gfxPlatformGtk::GetSurfaceGdkDrawable(gfxASurface *aSurf)
-{
- GdkDrawable *gd;
- gd = (GdkDrawable*) cairo_surface_get_user_data(aSurf->CairoSurface(), &cairo_gdk_pixmap_key);
- if (gd)
- return gd;
-
- gd = (GdkDrawable*) cairo_surface_get_user_data(aSurf->CairoSurface(), &cairo_gdk_window_key);
- if (gd)
- return gd;
-
- return nsnull;
-}
-
-void
-gfxPlatformGtk::SetSurfaceGdkWindow(gfxASurface *aSurf,
- GdkWindow *win)
-{
- cairo_surface_set_user_data(aSurf->CairoSurface(),
- &cairo_gdk_window_key,
- win,
- nsnull);
-}
-
nsresult
gfxPlatformGtk::GetFontList(const nsACString& aLangGroup,
const nsACString& aGenericFamily,
nsStringArray& aListOfFonts)
{
return sFontconfigUtils->GetFontList(aLangGroup, aGenericFamily,
aListOfFonts);
}
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -5926,22 +5926,21 @@ nsWindow::GetThebesSurface()
gint width, height;
gdk_drawable_get_size(d, &width, &height);
if (!gfxPlatform::UseGlitz()) {
mThebesSurface = new gfxXlibSurface
(GDK_WINDOW_XDISPLAY(d),
GDK_WINDOW_XWINDOW(d),
GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(d)),
gfxIntSize(width, height));
- if (mThebesSurface && !mThebesSurface->CairoStatus()) {
- gfxPlatformGtk::GetPlatform()->SetSurfaceGdkWindow(mThebesSurface, GDK_WINDOW(d));
- }
- else {
+
+ // if the surface creation is reporting an error, then
+ // we don't have a surface to give back
+ if (mThebesSurface && mThebesSurface->CairoStatus() != 0)
mThebesSurface = nsnull;
- }
} else {
#ifdef MOZ_ENABLE_GLITZ
glitz_surface_t *gsurf;
glitz_drawable_t *gdraw;
glitz_drawable_format_t *gdformat = glitz_glx_find_window_format (GDK_DISPLAY(),
gdk_x11_get_default_screen(),
0, NULL, 0);