From 476eaf16796abd91bf9965955aa479659a36a2ea Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Mon, 12 Mar 2012 18:11:10 +0000 Subject: [PATCH] Script: Fixed that SKIN:ParseFormula didn't work with numbers NowPlaying.dll: Fixed a few TagLib memory leaks. --- Library/lua/glue/LuaMeterWindow.cpp | 9 +++++---- Plugins/PluginNowPlaying/NowPlaying.cpp | 5 ----- Plugins/PluginNowPlaying/taglib/asf/asffile.cpp | 8 ++++++++ Plugins/PluginNowPlaying/taglib/mpeg/id3v1/id3v1tag.cpp | 7 +++++-- .../taglib/mpeg/id3v2/id3v2framefactory.cpp | 5 ++--- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/Library/lua/glue/LuaMeterWindow.cpp b/Library/lua/glue/LuaMeterWindow.cpp index 1e032972..584b48a5 100644 --- a/Library/lua/glue/LuaMeterWindow.cpp +++ b/Library/lua/glue/LuaMeterWindow.cpp @@ -106,13 +106,14 @@ static int ParseFormula(lua_State* L) std::wstring strTmp = LuaManager::ToWide(L, 2); double result; - if (self->GetParser().ParseFormula(strTmp, &result)) + if (!self->GetParser().ParseFormula(strTmp, &result)) { - lua_pushnumber(L, result); - return 1; + result = lua_tonumber(L, 2); } - return 0; + lua_pushnumber(L, result); + + return 1; } static int MoveWindow(lua_State* L) diff --git a/Plugins/PluginNowPlaying/NowPlaying.cpp b/Plugins/PluginNowPlaying/NowPlaying.cpp index 028a83e8..c7c79b7b 100644 --- a/Plugins/PluginNowPlaying/NowPlaying.cpp +++ b/Plugins/PluginNowPlaying/NowPlaying.cpp @@ -27,7 +27,6 @@ #include "PlayerWinamp.h" #include "PlayerWLM.h" #include "PlayerWMP.h" -#include "id3v1tag.h" static std::vector g_ParentMeasures; std::wstring g_SettingsFile; @@ -43,10 +42,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) // Disable DLL_THREAD_ATTACH and DLL_THREAD_DETACH notification calls DisableThreadLibraryCalls(hinstDLL); break; - - case DLL_PROCESS_DETACH: - TagLib::ID3v1::Tag::setStringHandler(NULL); - break; } return TRUE; diff --git a/Plugins/PluginNowPlaying/taglib/asf/asffile.cpp b/Plugins/PluginNowPlaying/taglib/asf/asffile.cpp index 0a947472..898c21d9 100644 --- a/Plugins/PluginNowPlaying/taglib/asf/asffile.cpp +++ b/Plugins/PluginNowPlaying/taglib/asf/asffile.cpp @@ -141,11 +141,19 @@ class ASF::File::HeaderExtensionObject : public ASF::File::BaseObject { public: List objects; + ~HeaderExtensionObject(); ByteVector guid(); void parse(ASF::File *file, uint size); ByteVector render(ASF::File *file); }; +ASF::File::HeaderExtensionObject::~HeaderExtensionObject() +{ + for(unsigned int i = 0; i < objects.size(); i++) { + delete objects[i]; + } +} + void ASF::File::BaseObject::parse(ASF::File *file, unsigned int size) { data.clear(); diff --git a/Plugins/PluginNowPlaying/taglib/mpeg/id3v1/id3v1tag.cpp b/Plugins/PluginNowPlaying/taglib/mpeg/id3v1/id3v1tag.cpp index 4a1d69b2..1457c81b 100644 --- a/Plugins/PluginNowPlaying/taglib/mpeg/id3v1/id3v1tag.cpp +++ b/Plugins/PluginNowPlaying/taglib/mpeg/id3v1/id3v1tag.cpp @@ -51,7 +51,8 @@ public: static const StringHandler *stringHandler; }; -const ID3v1::StringHandler *ID3v1::Tag::TagPrivate::stringHandler = new StringHandler; +static const StringHandler defaultStringHandler; +const ID3v1::StringHandler *ID3v1::Tag::TagPrivate::stringHandler = &defaultStringHandler; //////////////////////////////////////////////////////////////////////////////// // StringHandler implementation @@ -189,7 +190,9 @@ void ID3v1::Tag::setTrack(uint i) void ID3v1::Tag::setStringHandler(const StringHandler *handler) { - delete TagPrivate::stringHandler; + if(TagPrivate::stringHandler != &defaultStringHandler) + delete TagPrivate::stringHandler; + TagPrivate::stringHandler = handler; } diff --git a/Plugins/PluginNowPlaying/taglib/mpeg/id3v2/id3v2framefactory.cpp b/Plugins/PluginNowPlaying/taglib/mpeg/id3v2/id3v2framefactory.cpp index 356d60d4..a1067acc 100644 --- a/Plugins/PluginNowPlaying/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/Plugins/PluginNowPlaying/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -73,9 +73,8 @@ FrameFactory *FrameFactory::factory = 0; FrameFactory *FrameFactory::instance() { - if(!factory) - factory = new FrameFactory; - return factory; + static FrameFactory factory; + return &factory; } Frame *FrameFactory::createFrame(const ByteVector &data, bool synchSafeInts) const