Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Correcting minor bugs and adding assertions to help me track down a N…
Browse files Browse the repository at this point in the history
…ULL pointer bug in Cocoa code.
  • Loading branch information
egottlieb committed Aug 5, 2010
1 parent 5598e9d commit 727890d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/video/SDL_shape.c
Expand Up @@ -22,6 +22,7 @@
#include "SDL_config.h"

#include "SDL.h"
#include "SDL_assert.h"
#include "SDL_video.h"
#include "SDL_sysvideo.h"
#include "SDL_pixels.h"
Expand Down Expand Up @@ -197,6 +198,7 @@ SDL_ShapeTree* SDL_CalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* shap
}

void SDL_TraverseShapeTree(SDL_ShapeTree *tree,SDL_TraversalFunction function,void* closure) {
SDL_assert(tree != NULL);
if(tree->kind == QuadShape) {
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft,function,closure);
SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright,function,closure);
Expand Down
7 changes: 4 additions & 3 deletions src/video/cocoa/SDL_cocoashape.m
Expand Up @@ -28,7 +28,7 @@

SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) {
SDL_WindowData* data = (SDL_WindowData*)window->driverdata;
[data->nswindow setAlpha:1.0];
[data->nswindow setAlphaValue:1.0];
[data->nswindow setOpaque:YES];
[data->nswindow setStyleMask:NSBorderlessWindowMask];
SDL_WindowShaper* result = SDL_malloc(sizeof(SDL_WindowShaper));
Expand All @@ -45,7 +45,7 @@
shape_data->shape = NULL;

int resized_properly = Cocoa_ResizeWindowShape(window);
assert(resized_properly == 0);
SDL_assert(resized_properly == 0);
return result;
}

Expand All @@ -60,6 +60,7 @@ NSRect convert_rect(SDL_Rect rect,SDL_Window* window) {
}

void ConglomerateShapeTree(SDL_ShapeTree* tree,SDL_PathConglomeration* cong) {
SDL_assert(tree != NULL);
if(tree->kind == OpaqueShape) {
NSRect rect = convert_rect(tree->data.shape,cong->window);
[cong->clipPath appendBezierPathWithRect:rect];
Expand Down Expand Up @@ -91,7 +92,7 @@ int Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowS

int Cocoa_ResizeWindowShape(SDL_Window *window) {
SDL_ShapeData* data = window->shaper->driverdata;
assert(data != NULL);
SDL_assert(data != NULL);

if(data->shape != NULL)
SDL_FreeShapeTree(&data->shape);
Expand Down
9 changes: 5 additions & 4 deletions src/video/x11/SDL_x11shape.c
Expand Up @@ -20,7 +20,8 @@
eligottlieb@gmail.com
*/

#include <assert.h>
#include "SDL_assert.h"
#include "SDL_malloc.h"
#include "SDL_x11video.h"
#include "SDL_x11shape.h"
#include "SDL_x11window.h"
Expand All @@ -39,13 +40,13 @@ SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) {
result->mode.mode = ShapeModeDefault;
result->mode.parameters.binarizationCutoff = 1;
result->usershownflag = 0;
SDL_ShapeData* data = malloc(sizeof(SDL_ShapeData));
SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData));
result->driverdata = data;
data->bitmapsize = 0;
data->bitmap = NULL;
window->shaper = result;
int resized_properly = X11_ResizeWindowShape(window);
assert(resized_properly == 0);
SDL_assert(resized_properly == 0);
}
#endif

Expand All @@ -54,7 +55,7 @@ SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) {

int X11_ResizeWindowShape(SDL_Window* window) {
SDL_ShapeData* data = window->shaper->driverdata;
assert(data != NULL);
SDL_assert(data != NULL);

unsigned int bitmapsize = window->w / 8;
if(window->w % 8 > 0)
Expand Down

0 comments on commit 727890d

Please sign in to comment.