]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/private/error.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: gtk/private/error.h
3 // Purpose: Wrapper around GError.
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2012 Vadim Zeitlin <vadim@wxwidgets.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_GTK_PRIVATE_ERROR_H_
12 #define _WX_GTK_PRIVATE_ERROR_H_
14 // ----------------------------------------------------------------------------
15 // wxGtkError wraps GError and releases it automatically.
16 // ----------------------------------------------------------------------------
18 // Create an object of this class and pass the result of its Out() method to a
19 // function taking "GError**", then use GetMessage() if the function returned
24 wxGtkError() { m_error
= NULL
; }
25 ~wxGtkError() { if ( m_error
) g_error_free(m_error
); }
29 // This would result in a GError leak.
30 wxASSERT_MSG( !m_error
, wxS("Can't reuse the same object.") );
35 wxString
GetMessage() const
37 return wxString::FromUTF8(m_error
->message
);
43 wxDECLARE_NO_COPY_CLASS(wxGtkError
);
46 #endif // _WX_GTK_PRIVATE_ERROR_H_