X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=c%2B%2B%2Fcursesp.h;h=54b0d58899ecda6f380b553ec977add8c3f03087;hp=3d8828cb84e5386d3ed83d13e919fb6933df143e;hb=b0bdfbb1c78346047c54d8e516a104fcff586e52;hpb=2639531af0c3ca25b48e7bcb9c790fa566cc5892 diff --git a/c++/cursesp.h b/c++/cursesp.h index 3d8828cb..54b0d588 100644 --- a/c++/cursesp.h +++ b/c++/cursesp.h @@ -1,6 +1,6 @@ // * This makes emacs happy -*-Mode: C++;-*- /**************************************************************************** - * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2012,2014 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -34,7 +34,7 @@ #ifndef NCURSES_CURSESP_H_incl #define NCURSES_CURSESP_H_incl 1 -// $Id: cursesp.h,v 1.27 2007/04/07 17:12:54 tom Exp $ +// $Id: cursesp.h,v 1.31 2014/08/09 22:06:26 Adam.Jiang Exp $ #include @@ -71,19 +71,22 @@ protected: void set_user(void *user) { UserHook* uptr = UserPointer(); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p); - uptr->m_user = user; + if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) { + uptr->m_user = user; + } } // Set the user pointer of the panel. void *get_user() { UserHook* uptr = UserPointer(); - assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==p); - return uptr->m_user; + void *result = 0; + if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) + result = uptr->m_user; + return result; } - void OnError (int err) const THROWS(NCursesPanelException) + void OnError (int err) const THROW2(NCursesException const, NCursesPanelException) { if (err==ERR) THROW(new NCursesPanelException (this, err)); @@ -233,7 +236,8 @@ public: : NCursesPanel (nlines, ncols, begin_y, begin_x) { if (p) - set_user (const_cast(p_UserData)); + set_user (const_cast(reinterpret_cast + (p_UserData))); }; // This creates an user panel of the requested size with associated // user data pointed to by p_UserData. @@ -241,14 +245,14 @@ public: NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel() { if (p) - set_user(const_cast(p_UserData)); + set_user(const_cast(reinterpret_cast(p_UserData))); }; // This creates an user panel associated with the ::stdscr and user data // pointed to by p_UserData. virtual ~NCursesUserPanel() {}; - T* UserData (void) const + T* UserData (void) { return reinterpret_cast(get_user ()); }; @@ -257,7 +261,7 @@ public: virtual void setUserData (const T* p_UserData) { if (p) - set_user (const_cast(p_UserData)); + set_user (const_cast(reinterpret_cast(p_UserData))); } // Associate the user panel with the user data pointed to by p_UserData. };