]>
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
6 // Copyright: (c) 2012 Vadim Zeitlin <vadim@wxwidgets.org>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_PRIVATE_ERROR_H_
11 #define _WX_GTK_PRIVATE_ERROR_H_
13 // ----------------------------------------------------------------------------
14 // wxGtkError wraps GError and releases it automatically.
15 // ----------------------------------------------------------------------------
17 // Create an object of this class and pass the result of its Out() method to a
18 // function taking "GError**", then use GetMessage() if the function returned
23 wxGtkError() { m_error
= NULL
; }
24 ~wxGtkError() { if ( m_error
) g_error_free(m_error
); }
28 // This would result in a GError leak.
29 wxASSERT_MSG( !m_error
, wxS("Can't reuse the same object.") );
34 wxString
GetMessage() const
36 return wxString::FromUTF8(m_error
->message
);
42 wxDECLARE_NO_COPY_CLASS(wxGtkError
);
45 #endif // _WX_GTK_PRIVATE_ERROR_H_