added CONTEXT information to exceptions

svn path=/trunk/; revision=6754
This commit is contained in:
Martin Fuchs 2003-11-23 00:43:18 +00:00
parent 668ad67060
commit 915d0c21ff
6 changed files with 153 additions and 15 deletions

View file

@ -136,8 +136,8 @@ LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
COMPACT_RTF = YES
RTF_HYPERLINKS = YES
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------

View file

@ -1,11 +1,11 @@
/* Do not edit - Machine generated */
#ifndef _INC_REACTOS_BUILDNO
#define _INC_REACTOS_BUILDNO
#define KERNEL_VERSION_BUILD 23
#define KERNEL_VERSION_BUILD_STR "23"
#define KERNEL_RELEASE_RC "0.1.4.23\0"
#define KERNEL_RELEASE_STR "0.1.4.23"
#define KERNEL_VERSION_RC "0.1.4\0"
#define KERNEL_VERSION_STR "0.1.4"
#define KERNEL_VERSION_BUILD 0
#define KERNEL_VERSION_BUILD_STR "0"
#define KERNEL_RELEASE_RC "0.1.5.0\0"
#define KERNEL_RELEASE_STR "0.1.5.0"
#define KERNEL_VERSION_RC "0.1.5\0"
#define KERNEL_VERSION_STR "0.1.5"
#endif
/* EOF */

View file

@ -3,7 +3,7 @@
<tr>
<td><address style="align: right;"><small>
ROS Explore Source Code Documentation
<br>generated on 10.11.2003 by <a href="http://www.doxygen.org/index.html">
<br>generated on 15.11.2003 by <a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0>
</small></address>
</td>

View file

@ -130,6 +130,8 @@ void explorer_show_frame(HWND hwndDesktop, int cmdshow)
static void InitInstance(HINSTANCE hInstance)
{
CONTEXT("InitInstance");
setlocale(LC_COLLATE, ""); // set collating rules to local settings for compareName
// register frame window class
@ -147,6 +149,8 @@ static void InitInstance(HINSTANCE hInstance)
int explorer_main(HINSTANCE hInstance, HWND hwndDesktop, int cmdshow)
{
CONTEXT("explorer_main");
// initialize COM and OLE
OleInit usingCOM;
@ -185,6 +189,8 @@ int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
int main(int argc, char* argv[])
{
CONTEXT("main");
STARTUPINFO startupinfo;
int nShowCmd = SW_SHOWNORMAL;
@ -201,6 +207,8 @@ int main(int argc, char* argv[])
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nShowCmd)
{
CONTEXT("WinMain()");
// create desktop window and task bar only, if there is no other shell and we are
// the first explorer instance
BOOL startup_desktop = !IsAnyDesktopRunning();

View file

@ -62,16 +62,35 @@ LPWSTR wcscpyn(LPWSTR dest, LPCWSTR source, size_t count)
}
Context Context::s_main(TEXT("-NO-CONTEXT-"));
Context* Context::s_current = &Context::s_main;
// Exception Handler for COM exceptions
void HandleException(COMException& e, HWND hwnd)
{
SetLastError(0);
MessageBox(hwnd, e.ErrorMessage(), TEXT("ShellClasses COM Exception"), MB_ICONHAND|MB_OK);
String msg = e.ErrorMessage();
if (e._ctx) {
TCHAR buffer[BUFFER_LEN];
_stprintf(buffer, TEXT("%s\nContext: %s"), (LPCTSTR)msg, e._ctx);
msg = buffer;
}
if (!e._obj.empty()) {
TCHAR buffer[BUFFER_LEN];
_stprintf(buffer, TEXT("%s\nObject: %s"), (LPCTSTR)msg, (LPCTSTR)e._obj);
msg = buffer;
}
MessageBox(hwnd, msg, TEXT("ShellClasses COM Exception"), MB_ICONHAND|MB_OK);
// If displaying the error message box _with_ parent was not successfull, display it now without a parent window.
if (GetLastError() == ERROR_INVALID_WINDOW_HANDLE)
MessageBox(0, e.ErrorMessage(), TEXT("ShellClasses COM Exception"), MB_ICONHAND|MB_OK);
MessageBox(0, msg, TEXT("ShellClasses COM Exception"), MB_ICONHAND|MB_OK);
}
@ -95,6 +114,8 @@ ShellFolder& Desktop()
void CommonDesktop::init()
{
CONTEXT("CommonDesktop::init()");
if (!_desktop)
_desktop = new ShellFolder;
}
@ -122,6 +143,8 @@ HRESULT path_from_pidlA(IShellFolder* folder, LPCITEMIDLIST pidl, LPSTR buffer,
HRESULT path_from_pidlW(IShellFolder* folder, LPCITEMIDLIST pidl, LPWSTR buffer, int len)
{
CONTEXT("path_from_pidlW()");
StrRetW str;
HRESULT hr = folder->GetDisplayNameOf(pidl, SHGDN_FORPARSING, &str);
@ -136,6 +159,8 @@ HRESULT path_from_pidlW(IShellFolder* folder, LPCITEMIDLIST pidl, LPWSTR buffer,
HRESULT name_from_pidl(IShellFolder* folder, LPCITEMIDLIST pidl, LPTSTR buffer, int len, SHGDNF flags)
{
CONTEXT("name_from_pidl()");
StrRet str;
HRESULT hr = folder->GetDisplayNameOf(pidl, flags, &str);
@ -153,6 +178,8 @@ HRESULT name_from_pidl(IShellFolder* folder, LPCITEMIDLIST pidl, LPTSTR buffer,
ShellFolder::ShellFolder()
{
CONTEXT("ShellFolder::ShellFolder()");
IShellFolder* desktop;
CheckError(SHGetDesktopFolder(&desktop));
@ -164,11 +191,15 @@ ShellFolder::ShellFolder()
ShellFolder::ShellFolder(IShellFolder* p)
: super(p)
{
CONTEXT("ShellFolder::ShellFolder(IShellFolder*)");
p->AddRef();
}
ShellFolder::ShellFolder(IShellFolder* parent, LPCITEMIDLIST pidl)
{
CONTEXT("ShellFolder::ShellFolder(IShellFolder*, LPCITEMIDLIST)");
IShellFolder* ptr;
if (!pidl)
@ -185,6 +216,8 @@ ShellFolder::ShellFolder(IShellFolder* parent, LPCITEMIDLIST pidl)
ShellFolder::ShellFolder(LPCITEMIDLIST pidl)
{
CONTEXT("ShellFolder::ShellFolder(LPCITEMIDLIST)");
IShellFolder* ptr;
IShellFolder* parent = Desktop();
@ -199,6 +232,8 @@ ShellFolder::ShellFolder(LPCITEMIDLIST pidl)
void ShellFolder::attach(IShellFolder* parent, LPCITEMIDLIST pidl)
{
CONTEXT("ShellFolder::attach(IShellFolder*, LPCITEMIDLIST)");
IShellFolder* ptr;
if (pidl && pidl->mkid.cb)
@ -214,6 +249,8 @@ void ShellFolder::attach(IShellFolder* parent, LPCITEMIDLIST pidl)
ShellFolder::ShellFolder()
{
CONTEXT("ShellFolder::ShellFolder()");
CheckError(SHGetDesktopFolder(&_p));
_p->AddRef();
@ -222,11 +259,15 @@ ShellFolder::ShellFolder()
ShellFolder::ShellFolder(IShellFolder* p)
: super(p)
{
CONTEXT("ShellFolder::ShellFolder(IShellFolder*)");
_p->AddRef();
}
ShellFolder::ShellFolder(IShellFolder* parent, LPCITEMIDLIST pidl)
{
CONTEXT("ShellFolder::ShellFolder(IShellFolder*, LPCITEMIDLIST)");
if (pidl && pidl->mkid.cb)
CheckError(parent->BindToObject(pidl, 0, IID_IShellFolder, (LPVOID*)&_p));
else
@ -237,6 +278,8 @@ ShellFolder::ShellFolder(IShellFolder* parent, LPCITEMIDLIST pidl)
ShellFolder::ShellFolder(LPCITEMIDLIST pidl)
{
CONTEXT("ShellFolder::ShellFolder(LPCITEMIDLIST)");
if (pidl && pidl->mkid.cb)
CheckError(Desktop()->BindToObject(pidl, 0, IID_IShellFolder, (LPVOID*)&_p));
else
@ -247,6 +290,8 @@ ShellFolder::ShellFolder(LPCITEMIDLIST pidl)
void ShellFolder::attach(IShellFolder* parent, LPCITEMIDLIST pidl)
{
CONTEXT("ShellFolder::ShellFolder(IShellFolder*, LPCITEMIDLIST)");
IShellFolder* h = _p;
CheckError(parent->BindToObject(pidl, 0, IID_IShellFolder, (LPVOID*)&_p));
@ -259,6 +304,8 @@ void ShellFolder::attach(IShellFolder* parent, LPCITEMIDLIST pidl)
String ShellFolder::get_name(LPCITEMIDLIST pidl, SHGDNF flags) const
{
CONTEXT("ShellFolder::get_name()");
TCHAR buffer[MAX_PATH];
StrRet strret;
@ -299,6 +346,8 @@ void ShellPath::split(ShellPath& parent, ShellPath& obj) const
void ShellPath::GetUIObjectOf(REFIID riid, LPVOID* ppvOut, HWND hWnd, ShellFolder& sf)
{
CONTEXT("ShellPath::GetUIObjectOf()");
ShellPath parent, obj;
split(parent, obj);
@ -317,6 +366,8 @@ void ShellPath::GetUIObjectOf(REFIID riid, LPVOID* ppvOut, HWND hWnd, ShellFolde
// convert an item id list from relative to absolute (=relative to the desktop) format
ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl) const
{
CONTEXT("ShellPath::create_absolute_pidl()");
return ILCombine(parent_pidl, _p);
/* seems to work only for NT upwards
@ -337,6 +388,8 @@ ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl) const
ShellPath ShellPath::create_absolute_pidl(LPCITEMIDLIST parent_pidl) const
{
CONTEXT("ShellPath::create_absolute_pidl()");
static DynamicFct<LPITEMIDLIST(WINAPI*)(LPCITEMIDLIST, LPCITEMIDLIST)> ILCombine(TEXT("SHELL32"), 25);
if (ILCombine)

View file

@ -50,14 +50,14 @@ using namespace _com_util;
#ifndef _NO_COMUTIL
#define COMException _com_error
#define COMExceptionBase _com_error
#else
/// COM Exception class as replacement for _com_error
struct COMException
/// COM ExceptionBase class as replacement for _com_error
struct COMExceptionBase
{
COMException(HRESULT hr)
COMExceptionBase(HRESULT hr)
: _hr(hr)
{
}
@ -91,6 +91,59 @@ protected:
mutable String _msg;
};
#endif
struct Context
{
Context(LPCTSTR ctx)
: _ctx(ctx)
{
_last = s_current;
s_current = this;
}
~Context()
{
s_current = _last;
}
LPCTSTR _ctx;
Context* _last;
static Context* s_current;
static Context s_main;
};
#define CONTEXT(x) Context __ctx__(TEXT(x))
/// COM Exception with context information
struct COMException : public COMExceptionBase
{
typedef COMExceptionBase super;
COMException(HRESULT hr)
: super(hr)
{
_ctx = Context::s_current->_ctx;
}
COMException(HRESULT hr, const String& obj)
: super(hr),
_obj(obj)
{
_ctx = Context::s_current->_ctx;
}
LPCTSTR _ctx;
String _obj;
};
#ifdef _NO_COMUTIL
inline void CheckError(HRESULT hr)
{
if (FAILED(hr)) {
@ -485,6 +538,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
ShellPath(IShellFolder* folder, LPCWSTR path)
{
CONTEXT("ShellPath::ShellPath(IShellFolder*, LPCWSTR)");
if (path) {
ULONG l;
CheckError(folder->ParseDisplayName(0, 0, (LPOLESTR)path, &l, &_p, 0));
@ -494,6 +549,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
ShellPath(LPCWSTR path)
{
CONTEXT("ShellPath::ShellPath(LPCWSTR)");
if (path) {
ULONG l;
CheckError(Desktop()->ParseDisplayName(0, 0, (LPOLESTR)path, &l, &_p, 0));
@ -503,6 +560,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
ShellPath(IShellFolder* folder, LPCSTR path)
{
CONTEXT("ShellPath::ShellPath(IShellFolder*, LPCSTR)");
ULONG l;
WCHAR b[MAX_PATH];
@ -515,6 +574,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
ShellPath(LPCSTR path)
{
CONTEXT("ShellPath::ShellPath(LPCSTR)");
ULONG l;
WCHAR b[MAX_PATH];
@ -528,6 +589,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
ShellPath(const ShellPath& o)
: super(NULL)
{
//CONTEXT("ShellPath::ShellPath(const ShellPath&)");
if (o._p) {
int l = ILGetSize(o._p);
_p = (ITEMIDLIST*) _malloc->Alloc(l);
@ -542,6 +605,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
ShellPath(LPCITEMIDLIST p)
{
//CONTEXT("ShellPath::ShellPath(LPCITEMIDLIST)");
if (p) {
int l = ILGetSize(p);
_p = (ITEMIDLIST*) _malloc->Alloc(l);
@ -551,6 +616,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
void operator=(const ShellPath& o)
{
//CONTEXT("ShellPath::operator=(const ShellPath&)");
ITEMIDLIST* h = _p;
if (o._p) {
@ -567,6 +634,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
void operator=(ITEMIDLIST* p)
{
//CONTEXT("ShellPath::operator=(ITEMIDLIST*)");
ITEMIDLIST* h = _p;
if (p) {
@ -608,6 +677,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
void assign(LPCITEMIDLIST pidl, size_t size)
{
//CONTEXT("ShellPath::assign(LPCITEMIDLIST, size_t)");
ITEMIDLIST* h = _p;
_p = (ITEMIDLIST*) _malloc->Alloc(size+sizeof(USHORT/*SHITEMID::cb*/));
@ -622,6 +693,8 @@ struct ShellPath : public SShellPtr<ITEMIDLIST>
void assign(LPCITEMIDLIST pidl)
{
//CONTEXT("ShellPath::assign(LPCITEMIDLIST)");
ITEMIDLIST* h = _p;
if (pidl) {
@ -837,6 +910,8 @@ struct SpecialFolderFSPath : public FileSysShellPath
{
SpecialFolderFSPath(int folder, HWND hwnd)
{
CONTEXT("SpecialFolderFSPath::SpecialFolderFSPath()");
HRESULT hr = SHGetSpecialFolderLocation(hwnd, folder, &_p);
CheckError(hr);
}
@ -851,6 +926,8 @@ struct ShellItemEnumerator : public SIfacePtr<IEnumIDList>
{
ShellItemEnumerator(IShellFolder* folder, DWORD flags=SHCONTF_FOLDERS|SHCONTF_NONFOLDERS|SHCONTF_INCLUDEHIDDEN)
{
CONTEXT("ShellItemEnumerator::ShellItemEnumerator()");
CheckError(folder->EnumObjects(0, flags, &_p));
}
};