protect GetTemplateContent callers from exceptions
This commit is contained in:
parent
ed7c23c8d2
commit
c855d5e7cb
|
@ -8,15 +8,17 @@
|
||||||
#include "winrt-enums.h"
|
#include "winrt-enums.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
#define EXTERN extern "C"
|
||||||
{
|
#define NOEXCEPT noexcept
|
||||||
|
#else
|
||||||
|
#define EXTERN
|
||||||
|
#define NOEXCEPT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gboolean winrt_InitApartment();
|
EXTERN gboolean winrt_InitApartment();
|
||||||
char* winrt_windows_ui_notifications_toast_notification_manager_GetTemplateContent(winrtWindowsUINotificationsToastTemplateType type);
|
EXTERN char* winrt_windows_ui_notifications_toast_notification_manager_GetTemplateContent(winrtWindowsUINotificationsToastTemplateType type) NOEXCEPT;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#undef EXTERN
|
||||||
}
|
#undef NOEXCEPT
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // __WINRT_GLIB_2_H__
|
#endif // __WINRT_GLIB_2_H__
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include "gobject/winrt-private.h"
|
#include "gobject/winrt-private.h"
|
||||||
#include "converter.hpp"
|
#include "converter.hpp"
|
||||||
|
#include "ginvoke.hpp"
|
||||||
|
|
||||||
gboolean winrt_InitApartment()
|
gboolean winrt_InitApartment()
|
||||||
{
|
{
|
||||||
|
@ -24,8 +25,13 @@ gboolean winrt_InitApartment()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* winrt_windows_ui_notifications_toast_notification_manager_GetTemplateContent(winrtWindowsUINotificationsToastTemplateType type)
|
static char* ImplGetTemplateContent(winrtWindowsUINotificationsToastTemplateType type)
|
||||||
{
|
{
|
||||||
using namespace winrt::Windows::UI::Notifications;
|
using namespace winrt::Windows::UI::Notifications;
|
||||||
return wsview_to_char(ToastNotificationManager::GetTemplateContent(static_cast<ToastTemplateType>(type)).GetXml());
|
return wsview_to_char(ToastNotificationManager::GetTemplateContent(static_cast<ToastTemplateType>(type)).GetXml());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* winrt_windows_ui_notifications_toast_notification_manager_GetTemplateContent(winrtWindowsUINotificationsToastTemplateType type) noexcept
|
||||||
|
{
|
||||||
|
return g_try_invoke(ImplGetTemplateContent, type).value_or(nullptr);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue