Permalink
Browse files

Adds back signal handling and windows translated exception handling i…

…n a less platform specific manner while preserving the library dependency hierarchy.
  • Loading branch information...
1 parent 22980d8 commit cf3383acaee5381627dca140480ec53cee1084b2 @FernetMenta FernetMenta committed with Jim Carroll May 2, 2012
View
@@ -29,7 +29,6 @@ DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \
lib/xbmc-dll-symbols/dll-symbols.a \
xbmc/addons/addons.a \
xbmc/cdrip/cdrip.a \
- xbmc/commons/commons.a \
xbmc/cores/AudioEngine/audioengine.a \
xbmc/cores/DllLoader/dllloader.a \
xbmc/cores/DllLoader/exports/exports.a \
@@ -74,7 +73,6 @@ DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \
xbmc/rendering/rendering.a \
xbmc/settings/settings.a \
xbmc/storage/storage.a \
- xbmc/threads/threads.a \
xbmc/utils/utils.a \
xbmc/video/dialogs/videodialogs.a \
xbmc/video/video.a \
@@ -84,6 +82,10 @@ DIRECTORY_ARCHIVES=$(DVDPLAYER_ARCHIVES) \
xbmc/xbmc.a \
+NWAOBJSXBMC= xbmc/commons/commons.a \
+ xbmc/threads/threads.a \
+
+
ifeq (@USE_WEB_SERVER@,1)
DIRECTORY_ARCHIVES += xbmc/network/httprequesthandler/httprequesthandlers.a
endif
@@ -338,9 +340,9 @@ LIBS += @PYTHON_LDFLAGS@
xbmc.bin: $(OBJSXBMC) $(DYNOBJSXBMC) $(NWAOBJSXBMC)
ifeq ($(findstring osx,@ARCH@), osx)
- $(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(OBJSXBMC) $(LIBS) -rdynamic
+ $(SILENT_LD) $(CXX) $(LDFLAGS) -o xbmc.bin -Wl,-all_load,-ObjC $(DYNOBJSXBMC) $(NWAOBJSXBMC) $(OBJSXBMC) $(LIBS) -rdynamic
else
- $(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xbmc.bin -Wl,--whole-archive $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive $(LIBS) -rdynamic
+ $(SILENT_LD) $(CXX) $(CXXFLAGS) $(LDFLAGS) -o xbmc.bin -Wl,--whole-archive $(DYNOBJSXBMC) $(OBJSXBMC) -Wl,--no-whole-archive $(NWAOBJSXBMC) $(LIBS) -rdynamic
endif
xbmc-xrandr: xbmc-xrandr.c
@@ -1115,7 +1115,6 @@
<ClCompile Include="..\..\xbmc\utils\URIUtils.cpp" />
<ClCompile Include="..\..\xbmc\utils\Variant.cpp" />
<ClCompile Include="..\..\xbmc\utils\Weather.cpp" />
- <ClCompile Include="..\..\xbmc\utils\Win32Exception.cpp" />
<ClCompile Include="..\..\xbmc\utils\XBMCTinyXML.cpp" />
<ClCompile Include="..\..\xbmc\utils\XMLUtils.cpp" />
<ClCompile Include="..\..\xbmc\video\Bookmark.cpp" />
@@ -1911,7 +1910,6 @@
<ClInclude Include="..\..\xbmc\utils\URIUtils.h" />
<ClInclude Include="..\..\xbmc\utils\Variant.h" />
<ClInclude Include="..\..\xbmc\utils\Weather.h" />
- <ClInclude Include="..\..\xbmc\utils\Win32Exception.h" />
<ClInclude Include="..\..\xbmc\utils\XBMCTinyXML.h" />
<ClInclude Include="..\..\xbmc\utils\XMLUtils.h" />
<ClInclude Include="..\..\xbmc\video\Bookmark.h" />
@@ -2278,4 +2276,4 @@
</VisualStudio>
</ProjectExtensions>
<Import Project="$(SolutionDir)\$(ProjectFileName).targets.user" Condition="Exists('$(SolutionDir)\$(ProjectFileName).targets.user')" />
-</Project>
+</Project>
@@ -1672,9 +1672,6 @@
<ClCompile Include="..\..\xbmc\utils\Weather.cpp">
<Filter>utils</Filter>
</ClCompile>
- <ClCompile Include="..\..\xbmc\utils\Win32Exception.cpp">
- <Filter>utils</Filter>
- </ClCompile>
<ClCompile Include="..\..\xbmc\utils\XMLUtils.cpp">
<Filter>utils</Filter>
</ClCompile>
@@ -4262,9 +4259,6 @@
<ClInclude Include="..\..\xbmc\utils\Weather.h">
<Filter>utils</Filter>
</ClInclude>
- <ClInclude Include="..\..\xbmc\utils\Win32Exception.h">
- <Filter>utils</Filter>
- </ClInclude>
<ClInclude Include="..\..\xbmc\utils\XMLUtils.h">
<Filter>utils</Filter>
</ClInclude>
@@ -5204,4 +5198,4 @@
<Filter>win32</Filter>
</CustomBuild>
</ItemGroup>
-</Project>
+</Project>
@@ -11,9 +11,11 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="..\..\xbmc\commons\Exception.cpp" />
<ClCompile Include="..\..\xbmc\commons\ilog.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="..\..\xbmc\commons\Exception.h" />
<ClInclude Include="..\..\xbmc\commons\ilog.h" />
</ItemGroup>
<PropertyGroup Label="Globals">
@@ -2,8 +2,10 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\..\xbmc\commons\ilog.cpp" />
+ <ClCompile Include="..\..\xbmc\commons\Exception.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\commons\ilog.h" />
+ <ClInclude Include="..\..\xbmc\commons\Exception.h" />
</ItemGroup>
</Project>
@@ -19,6 +19,7 @@
<ClInclude Include="..\..\xbmc\threads\platform\ThreadImpl.cpp" />
<ClCompile Include="..\..\xbmc\threads\platform\Implementation.cpp" />
<ClInclude Include="..\..\xbmc\threads\platform\win\Implementation.cpp" />
+ <ClCompile Include="..\..\xbmc\threads\platform\win\Win32Exception.cpp" />
<ClCompile Include="..\..\xbmc\threads\SystemClock.cpp" />
<ClCompile Include="..\..\xbmc\threads\Thread.cpp" />
</ItemGroup>
@@ -37,6 +38,7 @@
<ClInclude Include="..\..\xbmc\threads\platform\win\CriticalSection.h" />
<ClInclude Include="..\..\xbmc\threads\platform\win\ThreadImpl.h" />
<ClInclude Include="..\..\xbmc\threads\platform\win\ThreadLocal.h" />
+ <ClInclude Include="..\..\xbmc\threads\platform\win\Win32Exception.h" />
<ClInclude Include="..\..\xbmc\threads\SharedSection.h" />
<ClInclude Include="..\..\xbmc\threads\SingleLock.h" />
<ClInclude Include="..\..\xbmc\threads\SystemClock.h" />
@@ -9,6 +9,9 @@
<ClCompile Include="..\..\xbmc\threads\platform\Implementation.cpp">
<Filter>platform</Filter>
</ClCompile>
+ <ClCompile Include="..\..\xbmc\threads\platform\win\Win32Exception.cpp">
+ <Filter>platform\win</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\xbmc\threads\Atomics.h" />
@@ -57,6 +60,9 @@
<ClInclude Include="..\..\xbmc\threads\platform\win\Implementation.cpp">
<Filter>platform\win</Filter>
</ClInclude>
+ <ClInclude Include="..\..\xbmc\threads\platform\win\Win32Exception.h">
+ <Filter>platform\win</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="platform">
View
@@ -143,7 +143,7 @@
#include "network/Zeroconf.h"
#include "network/ZeroconfBrowser.h"
#ifndef _LINUX
-#include "utils/Win32Exception.h"
+#include "threads/platform/win/Win32Exception.h"
#endif
#ifdef HAS_EVENT_SERVER
#include "network/EventServer.h"
View
@@ -22,6 +22,7 @@
#include "XbmcContext.h"
#include "threads/Thread.h"
+#include "commons/Exception.h"
#include "utils/log.h"
namespace XBMC
@@ -43,6 +44,7 @@ namespace XBMC
impl->loggerImpl = new XbmcUtils::LogImplementation;
// set
+ XbmcCommons::Exception::SetLogger(impl->loggerImpl);
CThread::SetLogger(impl->loggerImpl);
}
View
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#include "Exception.h"
+
+namespace XbmcCommons
+{
+ ILogger* Exception::logger = NULL;
+
+ Exception::~Exception() {}
+}
+
View
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2005-2012 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#pragma once
+
+//---------------------------------------------------------
+// This include should be moved to commons but even as it is,
+// it wont cause a linker circular dependency since it's just
+// a header.
+#include "utils/StdString.h"
+//---------------------------------------------------------
+#include "ilog.h"
+
+#define XBMCCOMMONS_COPYVARARGS(fmt) va_list argList; va_start(argList, fmt); Set(fmt, argList); va_end(argList)
+#define XBMCCOMMONS_STANDARD_EXCEPTION(E) \
+ class E : public XbmcCommons::Exception \
+ { \
+ public: \
+ inline E(const char* message,...) : Exception(#E) { XBMCCOMMONS_COPYVARARGS(message); } \
+ \
+ inline E(const E& other) : Exception(other) {} \
+ }
+
+namespace XbmcCommons
+{
+ /**
+ * This class a superclass for exceptions that want to utilize some
+ * utility functionality including autologging with the specific
+ * exception name.
+ */
+ class Exception
+ {
+ private:
+
+ std::string classname;
+ CStdString message;
+
+ protected:
+ static ILogger* logger;
+
+ inline Exception(const char* classname_) : classname(classname_) { }
+ inline Exception(const char* classname_, const char* message_) : classname(classname_), message(message_) { }
+ inline Exception(const Exception& other) : classname(other.classname), message(other.message) { }
+
+ /**
+ * This method is called from the constructor of subclasses. It
+ * will set the message from varargs as well as call log message
+ */
+ inline void Set(const char* fmt, va_list& argList)
+ {
+ message.FormatV(fmt, argList);
+ }
+
+ /**
+ * This message can be called from the constructor of subclasses.
+ * It will set the message and log the throwing.
+ */
+ inline void SetMessage(const char* fmt, ...)
+ {
+ // calls 'set'
+ XBMCCOMMONS_COPYVARARGS(fmt);
+ }
+
+ public:
+ virtual ~Exception();
+
+ inline virtual void LogThrowMessage(const char* prefix = NULL) const
+ {
+ if (logger)
+ logger->Log(LOGERROR,"EXCEPTION Thrown (%s) : %s", classname.c_str(), message.c_str());
+ }
+
+ inline virtual const char* GetMessage() const { return message.c_str(); }
+
+ inline static void SetLogger(ILogger* exceptionLogger) { logger = exceptionLogger; }
+ };
+
+ /**
+ * This class forms the base class for unchecked exceptions. Unchecked exceptions
+ * are those that really shouldn't be handled explicitly. For example, on windows
+ * when a access violaton is converted to a win32_exception, there's nothing
+ * that can be done in most code. The outer most stack frame might try to
+ * do some error logging prior to shutting down, but that's really it.
+ */
+ XBMCCOMMONS_STANDARD_EXCEPTION(UncheckedException);
+
+/**
+ * In cases where you catch(...){} you will (may) inadvertently be
+ * catching UncheckedException's. Therefore this macro will allow
+ * you to do something equivalent to:
+ * catch (anything except UncheckedException) {}
+ *
+ * In order to avoid catching UncheckedException, use the macro as follows:
+ *
+ * try { ... }
+ * XBMCCOMMONS_HANDLE_UNCHECKED
+ * catch(...){ ... }
+ */
+// Yes. I recognize that the name of this macro is an oxymoron.
+#define XBMCCOMMONS_HANDLE_UNCHECKED \
+ catch (const XbmcCommons::UncheckedException& ) { throw; } \
+ catch (const XbmcCommons::UncheckedException* ) { throw; }
+
+}
+
View
@@ -1,7 +1,7 @@
SRCS= \
+ Exception.cpp \
ilog.cpp
-
LIB=commons.a
include ../../Makefile.include
@@ -38,7 +38,7 @@ typedef struct _UNICODE_STRING {
USHORT MaximumLength;
PWSTR Buffer;
} UNICODE_STRING, *PUNICODE_STRING;
-#include "utils/Win32Exception.h"
+#include "commons/Exception.h"
#define DLL_PROCESS_DETACH 0
#define DLL_PROCESS_ATTACH 1
@@ -683,11 +683,7 @@ bool DllLoader::Load()
#endif
}
- catch(win32_exception &e)
- {
- e.writelog(__FUNCTION__);
- return false;
- }
+ XBMCCOMMONS_HANDLE_UNCHECKED
catch(...)
{
CLog::Log(LOGERROR, "%s - Unhandled exception during DLL_PROCESS_ATTACH", __FUNCTION__);
@@ -25,7 +25,6 @@
#include "DVDOverlayImage.h"
#include "DVDStreamInfo.h"
#include "DVDClock.h"
-#include "utils/Win32Exception.h"
#include "utils/log.h"
#include "utils/EndianSwap.h"
@@ -160,15 +159,7 @@ int CDVDOverlayCodecFFmpeg::Decode(BYTE* data, int size, double pts, double dura
avpkt.data = data;
avpkt.size = size;
- try
- {
- len = m_dllAvCodec.avcodec_decode_subtitle2(m_pCodecContext, &m_Subtitle, &gotsub, &avpkt);
- }
- catch (win32_exception e)
- {
- e.writelog("avcodec_decode_subtitle");
- return OC_ERROR;
- }
+ len = m_dllAvCodec.avcodec_decode_subtitle2(m_pCodecContext, &m_Subtitle, &gotsub, &avpkt);
if (len < 0)
{
@@ -197,13 +188,7 @@ void CDVDOverlayCodecFFmpeg::Flush()
FreeSubtitle(m_Subtitle);
m_SubtitleIndex = -1;
- try {
-
m_dllAvCodec.avcodec_flush_buffers(m_pCodecContext);
-
- } catch (win32_exception e) {
- e.writelog(__FUNCTION__);
- }
}
CDVDOverlay* CDVDOverlayCodecFFmpeg::GetOverlay()
Oops, something went wrong.

0 comments on commit cf3383a

Please sign in to comment.