From 3c2bd1bd9c2265391ea6fc40f99b274602ca5102 Mon Sep 17 00:00:00 2001 From: rude Date: Sat, 5 Sep 2009 16:14:52 +0200 Subject: [PATCH] Fixed epic bug in runtime.cpp causing non-Lua-owned objects to be released by Lua GC. --- platform/msvc2008/common/common.vcproj | 128 ++++++++ .../msvc2008/filesystem/filesystem.vcproj | 96 ++++++ platform/msvc2008/font/font.vcproj | 74 ++++- platform/msvc2008/graphics/graphics.vcproj | 162 +++++++++- platform/msvc2008/image/image.vcproj | 8 + platform/msvc2008/love.vcproj | 296 ++++++++++++++++++ platform/msvc2008/lovedll/lovedll.vcproj | 32 ++ platform/msvc2008/native/native.vcproj | 16 + platform/msvc2008/physics/physics.vcproj | 224 +++++++++++++ platform/msvc2008/signal/signal.vcproj | 2 + src/common/runtime.cpp | 7 +- src/modules/image/devil/ImageData.cpp | 3 +- 12 files changed, 1038 insertions(+), 10 deletions(-) diff --git a/platform/msvc2008/common/common.vcproj b/platform/msvc2008/common/common.vcproj index 7f0394a54..ea6c39744 100644 --- a/platform/msvc2008/common/common.vcproj +++ b/platform/msvc2008/common/common.vcproj @@ -157,6 +157,22 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -245,7 +277,15 @@ > + + + @@ -261,7 +301,15 @@ > + + + @@ -277,7 +325,15 @@ > + + + @@ -293,7 +349,15 @@ > + + + diff --git a/platform/msvc2008/graphics/graphics.vcproj b/platform/msvc2008/graphics/graphics.vcproj index a2a5d9c73..d2f6f3e2e 100644 --- a/platform/msvc2008/graphics/graphics.vcproj +++ b/platform/msvc2008/graphics/graphics.vcproj @@ -180,7 +180,15 @@ > + + + @@ -195,6 +203,14 @@ ObjectFile="$(IntDir)\graphics\opengl\" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/msvc2008/love.vcproj b/platform/msvc2008/love.vcproj index 77b3c0991..834d388a1 100644 --- a/platform/msvc2008/love.vcproj +++ b/platform/msvc2008/love.vcproj @@ -605,6 +605,22 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1520,6 +1672,22 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/platform/msvc2008/lovedll/lovedll.vcproj b/platform/msvc2008/lovedll/lovedll.vcproj index cf6531f61..2ba6c86a6 100644 --- a/platform/msvc2008/lovedll/lovedll.vcproj +++ b/platform/msvc2008/lovedll/lovedll.vcproj @@ -173,6 +173,22 @@ + + + + + + + + + + + + diff --git a/platform/msvc2008/native/native.vcproj b/platform/msvc2008/native/native.vcproj index 4212f0876..08f33c109 100644 --- a/platform/msvc2008/native/native.vcproj +++ b/platform/msvc2008/native/native.vcproj @@ -183,6 +183,14 @@ ObjectFile="$(IntDir)\native\tcc\" /> + + + + + + diff --git a/platform/msvc2008/physics/physics.vcproj b/platform/msvc2008/physics/physics.vcproj index c58841fc2..c66b6c607 100644 --- a/platform/msvc2008/physics/physics.vcproj +++ b/platform/msvc2008/physics/physics.vcproj @@ -183,6 +183,14 @@ ObjectFile="$(IntDir)\physics\box2d\" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -121,6 +122,7 @@ RuntimeLibrary="0" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" + ObjectFile="$(IntDir)\physics\box2d\" WarningLevel="3" DebugInformationFormat="3" /> diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index 3d072a00a..caeb31742 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -37,9 +37,10 @@ namespace love **/ static int w__gc(lua_State * L) { - Proxy * u = (Proxy *)lua_touserdata(L, 1); - Object * t = (Object *)u->data; - t->release(); + Proxy * p = (Proxy *)lua_touserdata(L, 1); + Object * t = (Object *)p->data; + if(p->own) + t->release(); return 0; } diff --git a/src/modules/image/devil/ImageData.cpp b/src/modules/image/devil/ImageData.cpp index 1f38032af..03f1866ef 100644 --- a/src/modules/image/devil/ImageData.cpp +++ b/src/modules/image/devil/ImageData.cpp @@ -171,6 +171,7 @@ namespace devil ILuint h = d->getHeight(); int headerLen, bpp; switch (f) { + case Image::FORMAT_TGA: // MSVC issues warning when there's no case statement. default: // since we only support one format headerLen = 18; bpp = 3; @@ -202,7 +203,7 @@ namespace devil ILubyte * temp = new ILubyte[row]; ILubyte * src = data - row; ILubyte * dst = data + size; - for (int i = 0; i < (h >> 1); i++) { + for (unsigned i = 0; i < (h >> 1); i++) { memcpy(temp,src+=row,row); memcpy(src,dst-=row,row); memcpy(dst,temp,row);