Integrate C++11 branch into 5_1-new
This commit is contained in:
@@ -100,7 +100,7 @@ static int waittid( int ThreadID, int *status, int options )
|
||||
static int PtraceAttach( int ThreadID )
|
||||
{
|
||||
int ret;
|
||||
ret = ptrace( PTRACE_ATTACH, ThreadID, NULL, NULL );
|
||||
ret = ptrace( PTRACE_ATTACH, ThreadID, nullptr, nullptr );
|
||||
if( ret == -1 )
|
||||
{
|
||||
printf("ptrace failed: %s\n", strerror(errno) );
|
||||
@@ -120,7 +120,7 @@ static int PtraceAttach( int ThreadID )
|
||||
|
||||
static int PtraceDetach( int ThreadID )
|
||||
{
|
||||
return ptrace( PTRACE_DETACH, ThreadID, NULL, NULL );
|
||||
return ptrace( PTRACE_DETACH, ThreadID, nullptr, nullptr );
|
||||
}
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ bool GetThreadBacktraceContext( uint64_t ThreadID, BacktraceContext *ctx )
|
||||
|
||||
#if defined(CPU_X86_64) || defined(CPU_X86)
|
||||
user_regs_struct regs;
|
||||
if( ptrace( PTRACE_GETREGS, pid_t(ThreadID), NULL, ®s ) == -1 )
|
||||
if( ptrace( PTRACE_GETREGS, pid_t(ThreadID), nullptr, ®s ) == -1 )
|
||||
return false;
|
||||
|
||||
ctx->pid = pid_t(ThreadID);
|
||||
|
||||
@@ -24,7 +24,7 @@ RString CrashHandler::GetLogsDirectory()
|
||||
}
|
||||
|
||||
// XXX Can we use LocalizedString here instead?
|
||||
#define LSTRING(b,x) CFBundleCopyLocalizedString( (b), CFSTR(x), NULL, CFSTR("Localizable") )
|
||||
#define LSTRING(b,x) CFBundleCopyLocalizedString( (b), CFSTR(x), nullptr, CFSTR("Localizable") )
|
||||
|
||||
void CrashHandler::InformUserOfCrash( const RString& sPath )
|
||||
{
|
||||
@@ -41,12 +41,12 @@ void CrashHandler::InformUserOfCrash( const RString& sPath )
|
||||
CFStringRef sFormat = LSTRING( bundle, PRODUCT_FAMILY " has crashed. "
|
||||
"Debugging information has been output to\n\n%s\n\n"
|
||||
"Please file a bug report at\n\n%s" );
|
||||
CFStringRef sBody = CFStringCreateWithFormat( kCFAllocatorDefault, NULL, sFormat,
|
||||
CFStringRef sBody = CFStringCreateWithFormat( kCFAllocatorDefault, nullptr, sFormat,
|
||||
sPath.c_str(), REPORT_BUG_URL );
|
||||
CFOptionFlags response = kCFUserNotificationCancelResponse;
|
||||
CFTimeInterval timeout = 0.0; // Should we ever time out?
|
||||
|
||||
CFUserNotificationDisplayAlert( timeout, kCFUserNotificationStopAlertLevel, NULL, NULL, NULL,
|
||||
CFUserNotificationDisplayAlert( timeout, kCFUserNotificationStopAlertLevel, nullptr, nullptr, nullptr,
|
||||
sTitle, sBody, sDefault, sAlternate, sOther, &response );
|
||||
|
||||
switch( response )
|
||||
@@ -86,7 +86,7 @@ bool CrashHandler::IsDebuggerPresent()
|
||||
|
||||
// Call sysctl.
|
||||
size = sizeof( info );
|
||||
ret = sysctl( mib, sizeof(mib)/sizeof(*mib), &info, &size, NULL, 0 );
|
||||
ret = sysctl( mib, sizeof(mib)/sizeof(*mib), &info, &size, nullptr, 0 );
|
||||
|
||||
// We're being debugged if the P_TRACED flag is set.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "HIDDevice.h"
|
||||
#include "RageUtil.h"
|
||||
|
||||
HIDDevice::HIDDevice() : m_Interface( NULL ), m_Queue( NULL ), m_bRunning( false )
|
||||
HIDDevice::HIDDevice() : m_Interface(nullptr), m_Queue(nullptr), m_bRunning( false )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ bool HIDDevice::Open( io_object_t device )
|
||||
if( hresult != S_OK )
|
||||
{
|
||||
LOG->Warn( "Couldn't get device interface from plugin interface." );
|
||||
m_Interface = NULL;
|
||||
m_Interface = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ bool HIDDevice::Open( io_object_t device )
|
||||
{
|
||||
PrintIOErr( ret, "Failed to open the interface." );
|
||||
CALL( m_Interface, Release );
|
||||
m_Interface = NULL;
|
||||
m_Interface = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,9 +133,9 @@ bool HIDDevice::Open( io_object_t device )
|
||||
{
|
||||
PrintIOErr( ret, "Failed to create the queue." );
|
||||
CALL( m_Queue, Release );
|
||||
m_Queue = NULL;
|
||||
m_Queue = nullptr;
|
||||
CALL( m_Interface, Release );
|
||||
m_Interface = NULL;
|
||||
m_Interface = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ protected:
|
||||
// Perform a synchronous set report on the HID interface.
|
||||
inline IOReturn SetReport( IOHIDReportType type, UInt32 reportID, void *buffer, UInt32 size, UInt32 timeoutMS )
|
||||
{
|
||||
return CALL( m_Interface, setReport, type, reportID, buffer, size, timeoutMS, NULL, NULL, NULL );
|
||||
return CALL( m_Interface, setReport, type, reportID, buffer, size, timeoutMS, nullptr, nullptr, nullptr );
|
||||
}
|
||||
public:
|
||||
HIDDevice();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "JoystickDevice.h"
|
||||
#include "RageLog.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
using __gnu_cxx::hash_map;
|
||||
|
||||
@@ -128,9 +127,8 @@ void JoystickDevice::AddElement( int usagePage, int usage, IOHIDElementCookie co
|
||||
void JoystickDevice::Open()
|
||||
{
|
||||
// Add elements to the queue for each Joystick
|
||||
FOREACH_CONST( Joystick, m_vSticks, i )
|
||||
for (Joystick const &js : m_vSticks)
|
||||
{
|
||||
const Joystick& js = *i;
|
||||
#define ADD(x) if( js.x ) AddElementToQueue( js.x )
|
||||
ADD( x_axis ); ADD( y_axis ); ADD( z_axis );
|
||||
ADD( x_rot ); ADD( y_rot ); ADD( z_rot );
|
||||
@@ -156,10 +154,8 @@ bool JoystickDevice::InitDevice( int vid, int pid )
|
||||
|
||||
void JoystickDevice::GetButtonPresses( vector<DeviceInput>& vPresses, IOHIDElementCookie cookie, int value, const RageTimer& now ) const
|
||||
{
|
||||
FOREACH_CONST( Joystick, m_vSticks, i )
|
||||
for (Joystick const &js : m_vSticks)
|
||||
{
|
||||
const Joystick& js = *i;
|
||||
|
||||
if( js.x_axis == cookie )
|
||||
{
|
||||
float level = SCALE( value, js.x_min, js.x_max, -1.0f, 1.0f );
|
||||
@@ -251,7 +247,7 @@ int JoystickDevice::AssignIDs( InputDevice startID )
|
||||
{
|
||||
if( !IsJoystick(startID) )
|
||||
return -1;
|
||||
FOREACH( Joystick, m_vSticks, i )
|
||||
for (auto i = m_vSticks.begin(); i != m_vSticks.end(); ++i)
|
||||
{
|
||||
if( !IsJoystick(startID) )
|
||||
{
|
||||
@@ -266,8 +262,8 @@ int JoystickDevice::AssignIDs( InputDevice startID )
|
||||
|
||||
void JoystickDevice::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const
|
||||
{
|
||||
FOREACH_CONST( Joystick, m_vSticks, i )
|
||||
vDevices.push_back( InputDeviceInfo(i->id,GetDescription()) );
|
||||
for (auto &i : m_vSticks)
|
||||
vDevices.push_back( InputDeviceInfo(i.id,GetDescription()) );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -191,8 +191,8 @@ static void SetupMenus( void )
|
||||
[item setKeyEquivalentModifierMask:NSAlternateKeyMask]; // opt-enter
|
||||
[windowMenu addItem:item];
|
||||
|
||||
[[mainMenu addItemWithTitle:[appMenu title] action:NULL keyEquivalent:@""] setSubmenu:appMenu];
|
||||
[[mainMenu addItemWithTitle:[windowMenu title] action:NULL keyEquivalent:@""] setSubmenu:windowMenu];
|
||||
[[mainMenu addItemWithTitle:[appMenu title] action:nil keyEquivalent:@""] setSubmenu:appMenu];
|
||||
[[mainMenu addItemWithTitle:[windowMenu title] action:nil keyEquivalent:@""] setSubmenu:windowMenu];
|
||||
|
||||
[NSApp setMainMenu:mainMenu];
|
||||
[NSApp setAppleMenu:appMenu]; // This isn't the apple menu, but it doesn't work without this.
|
||||
|
||||
@@ -10,7 +10,7 @@ bool Vector::CheckForVector()
|
||||
int32_t result = 0;
|
||||
size_t size = 4;
|
||||
|
||||
return !sysctlbyname( "hw.vectorunit", &result, &size, NULL, 0 ) && result;
|
||||
return !sysctlbyname( "hw.vectorunit", &result, &size, nullptr, 0 ) && result;
|
||||
}
|
||||
|
||||
/* for( unsigned pos = 0; pos < size; ++pos )
|
||||
|
||||
@@ -103,7 +103,7 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
while( got < size-1 )
|
||||
{
|
||||
char *p = (char *) memchr( file, '\n', file_used );
|
||||
if( p == NULL )
|
||||
if( p == nullptr )
|
||||
break;
|
||||
*p++ = 0;
|
||||
|
||||
@@ -114,13 +114,13 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
|
||||
/* Search for the hyphen. */
|
||||
char *hyphen = strchr( line, '-' );
|
||||
if( hyphen == NULL )
|
||||
if( hyphen == nullptr )
|
||||
continue; /* Parse error. */
|
||||
|
||||
|
||||
/* Search for the space. */
|
||||
char *space = strchr( hyphen, ' ' );
|
||||
if( space == NULL )
|
||||
if( space == nullptr )
|
||||
continue; /* Parse error. */
|
||||
|
||||
/* " rwxp". If space[1] isn't 'r', then the block isn't readable. */
|
||||
@@ -132,10 +132,10 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
if( strlen(space) < 4 || space[3] != 'x' )
|
||||
continue;
|
||||
|
||||
/* If, for some reason, either end is NULL, skip it; that's our terminator. */
|
||||
/* If, for some reason, either end is nullptr, skip it; that's our terminator. */
|
||||
const void *start = (const void *) xtoi( line );
|
||||
const void *end = (const void *) xtoi( hyphen+1 );
|
||||
if( start != NULL && end != NULL )
|
||||
if( start != nullptr && end != nullptr )
|
||||
{
|
||||
*starts++ = start;
|
||||
*ends++ = end;
|
||||
@@ -153,8 +153,8 @@ static int get_readable_ranges( const void **starts, const void **ends, int size
|
||||
|
||||
close(fd);
|
||||
|
||||
*starts++ = NULL;
|
||||
*ends++ = NULL;
|
||||
*starts++ = nullptr;
|
||||
*ends++ = nullptr;
|
||||
|
||||
return got;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ static int find_address( const void *p, const void **starts, const void **ends )
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void *SavedStackPointer = NULL;
|
||||
static void *SavedStackPointer = nullptr;
|
||||
|
||||
void InitializeBacktrace()
|
||||
{
|
||||
@@ -380,7 +380,7 @@ static void do_backtrace( const void **buf, size_t size, const BacktraceContext
|
||||
frame = frame->link;
|
||||
}
|
||||
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
}
|
||||
|
||||
#if defined(CPU_X86)
|
||||
@@ -408,11 +408,11 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
InitializeBacktrace();
|
||||
|
||||
BacktraceContext CurrentCtx;
|
||||
if( ctx == NULL )
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
ctx = &CurrentCtx;
|
||||
|
||||
CurrentCtx.ip = NULL;
|
||||
CurrentCtx.ip = nullptr;
|
||||
CurrentCtx.bp = __builtin_frame_address(0);
|
||||
CurrentCtx.sp = __builtin_frame_address(0);
|
||||
CurrentCtx.pid = GetCurrentThreadId();
|
||||
@@ -543,16 +543,16 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
if( g_StackPointer == 0 )
|
||||
{
|
||||
buf[0] = BACKTRACE_METHOD_NOT_AVAILABLE;
|
||||
buf[1] = NULL;
|
||||
buf[1] = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
BacktraceContext CurrentCtx;
|
||||
if( ctx == NULL )
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
ctx = &CurrentCtx;
|
||||
|
||||
CurrentCtx.ip = NULL;
|
||||
CurrentCtx.ip = nullptr;
|
||||
CurrentCtx.bp = __builtin_frame_address(0);
|
||||
CurrentCtx.sp = __builtin_frame_address(0);
|
||||
}
|
||||
@@ -582,7 +582,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
/* There isn't much we can do if this is the case. The stack should be read/write
|
||||
* and since it isn't, give up. */
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
return;
|
||||
}
|
||||
const Frame *frame = (Frame *)ctx->sp;
|
||||
@@ -640,7 +640,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
frame = frame->link;
|
||||
}
|
||||
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
}
|
||||
#undef PROT_RW
|
||||
#undef PROT_EXE
|
||||
@@ -664,14 +664,14 @@ void InitializeBacktrace() { }
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
BacktraceContext CurrentCtx;
|
||||
if( ctx == NULL )
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
ctx = &CurrentCtx;
|
||||
|
||||
/* __builtin_frame_address is broken on OS X; it sometimes returns bogus results. */
|
||||
register void *r1 __asm__ ("r1");
|
||||
CurrentCtx.FramePtr = (const Frame *) r1;
|
||||
CurrentCtx.PC = NULL;
|
||||
CurrentCtx.PC = nullptr;
|
||||
}
|
||||
|
||||
const Frame *frame = ctx->FramePtr;
|
||||
@@ -688,7 +688,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
frame = frame->stackPointer;
|
||||
}
|
||||
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
}
|
||||
|
||||
#elif defined(BACKTRACE_METHOD_PPC_LINUX)
|
||||
@@ -713,13 +713,13 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
BacktraceContext CurrentCtx;
|
||||
|
||||
if( ctx == NULL )
|
||||
if( ctx == nullptr )
|
||||
{
|
||||
ctx = &CurrentCtx;
|
||||
|
||||
register void *r1 __asm__("1");
|
||||
CurrentCtx.FramePtr = (const Frame *)r1;
|
||||
CurrentCtx.PC = NULL;
|
||||
CurrentCtx.PC = nullptr;
|
||||
}
|
||||
|
||||
const Frame *frame = (const Frame *)ctx->FramePtr;
|
||||
@@ -733,7 +733,7 @@ void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
if( frame->linkReg )
|
||||
buf[i++] = frame->linkReg;
|
||||
}
|
||||
buf[i] = NULL;
|
||||
buf[i] = nullptr;
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -744,7 +744,7 @@ void InitializeBacktrace() { }
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx )
|
||||
{
|
||||
buf[0] = BACKTRACE_METHOD_NOT_AVAILABLE;
|
||||
buf[1] = NULL;
|
||||
buf[1] = nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,10 +31,10 @@ struct BacktraceContext
|
||||
void InitializeBacktrace();
|
||||
|
||||
/* Retrieve up to size-1 backtrace pointers in buf. The array will be
|
||||
* null-terminated. If ctx is NULL, retrieve the current backtrace; otherwise
|
||||
* null-terminated. If ctx is nullptr, retrieve the current backtrace; otherwise
|
||||
* retrieve a backtrace for the given context. (Not all backtracers may
|
||||
* support contexts.) */
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx = NULL );
|
||||
void GetBacktrace( const void **buf, size_t size, const BacktraceContext *ctx = nullptr );
|
||||
|
||||
/* Set up a BacktraceContext to get a backtrace for a thread. ThreadID may
|
||||
* not be the current thread. True is returned on success, false on failure. */
|
||||
|
||||
@@ -44,7 +44,7 @@ void BacktraceNames::Demangle()
|
||||
return;
|
||||
|
||||
int status = 0;
|
||||
char *name = abi::__cxa_demangle( Symbol, NULL, NULL, &status );
|
||||
char *name = abi::__cxa_demangle( Symbol, nullptr, nullptr, &status );
|
||||
if( name )
|
||||
{
|
||||
Symbol = name;
|
||||
@@ -121,7 +121,7 @@ void BacktraceNames::FromAddr( void * const p )
|
||||
* between one function and the next, because the first lookup will succeed.
|
||||
*/
|
||||
Dl_info di;
|
||||
if( !dladdr((void *) p, &di) || di.dli_sname == NULL )
|
||||
if( !dladdr((void *) p, &di) || di.dli_sname == nullptr )
|
||||
{
|
||||
if( !dladdr( ((char *) p) - 8, &di) )
|
||||
return;
|
||||
@@ -177,7 +177,7 @@ static int osx_find_image( const void *p )
|
||||
for( unsigned i = 0; i < image_count; i++ )
|
||||
{
|
||||
const struct mach_header *header = _dyld_get_image_header(i);
|
||||
if( header == NULL )
|
||||
if( header == nullptr )
|
||||
continue;
|
||||
|
||||
/* The load commands directly follow the mach_header. */
|
||||
@@ -219,7 +219,7 @@ static const char *osx_find_link_edit( const struct mach_header *header )
|
||||
return (char *) ( scmd->vmaddr - scmd->fileoff );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BacktraceNames::FromAddr( void * const p )
|
||||
@@ -235,7 +235,7 @@ void BacktraceNames::FromAddr( void * const p )
|
||||
|
||||
/* Find the link-edit pointer. */
|
||||
const char *link_edit = osx_find_link_edit( _dyld_get_image_header(index) );
|
||||
if( link_edit == NULL )
|
||||
if( link_edit == nullptr )
|
||||
return;
|
||||
link_edit += _dyld_get_image_vmaddr_slide( index );
|
||||
|
||||
@@ -244,8 +244,8 @@ void BacktraceNames::FromAddr( void * const p )
|
||||
const struct load_command *cmd = (struct load_command *) &header[1];
|
||||
unsigned long diff = 0xffffffff;
|
||||
|
||||
const char *dli_sname = NULL;
|
||||
void *dli_saddr = NULL;
|
||||
const char *dli_sname = nullptr;
|
||||
void *dli_saddr = nullptr;
|
||||
|
||||
for( unsigned long i = 0; i < header->ncmds; i++, cmd = next_load_command(cmd) )
|
||||
{
|
||||
@@ -299,7 +299,7 @@ void BacktraceNames::FromAddr( void * const p )
|
||||
Address = (intptr_t) p;
|
||||
|
||||
char **foo = backtrace_symbols(&p, 1);
|
||||
if( foo == NULL )
|
||||
if( foo == nullptr )
|
||||
return;
|
||||
FromString( foo[0] );
|
||||
free(foo);
|
||||
|
||||
@@ -34,7 +34,7 @@ static void safe_print( int fd, ... )
|
||||
for(;;)
|
||||
{
|
||||
const char *p = va_arg( ap, const char * );
|
||||
if( p == NULL )
|
||||
if( p == nullptr )
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -88,13 +88,13 @@ static void NORETURN spawn_child_process( int from_parent )
|
||||
strncpy( magic, CHILD_MAGIC_PARAMETER, sizeof(magic) );
|
||||
|
||||
/* Use execve; it's the lowest-level of the exec calls. The others may allocate. */
|
||||
char *argv[3] = { path, magic, NULL };
|
||||
char *envp[1] = { NULL };
|
||||
char *argv[3] = { path, magic, nullptr };
|
||||
char *envp[1] = { nullptr };
|
||||
execve( path, argv, envp );
|
||||
|
||||
/* If we got here, the exec failed. We can't call strerror. */
|
||||
// safe_print(fileno(stderr), "Crash handler execl(", path, ") failed: ", strerror(errno), "\n", NULL);
|
||||
safe_print( fileno(stderr), "Crash handler execl(", path, ") failed: ", itoa( errno ), "\n", NULL );
|
||||
// safe_print(fileno(stderr), "Crash handler execl(", path, ") failed: ", strerror(errno), "\n", nullptr);
|
||||
safe_print( fileno(stderr), "Crash handler execl(", path, ") failed: ", itoa( errno ), "\n", nullptr );
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
@@ -116,13 +116,13 @@ static bool parent_write( int to_child, const void *p, size_t size )
|
||||
int ret = retried_write( to_child, p, size );
|
||||
if( ret == -1 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", strerror(errno), ")\n", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", strerror(errno), ")\n", nullptr );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( size_t(ret) != size )
|
||||
{
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", itoa(ret), ")\n", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected write() result (", itoa(ret), ")\n", nullptr );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ static void parent_process( int to_child, const CrashData *crash )
|
||||
/* 4. Write RecentLogs. */
|
||||
int cnt = 0;
|
||||
const char *ps[1024];
|
||||
while( cnt < 1024 && (ps[cnt] = RageLog::GetRecentLog( cnt )) != NULL )
|
||||
while( cnt < 1024 && (ps[cnt] = RageLog::GetRecentLog( cnt )) != nullptr )
|
||||
++cnt;
|
||||
|
||||
parent_write(to_child, &cnt, sizeof(cnt));
|
||||
@@ -211,9 +211,9 @@ static void parent_process( int to_child, const CrashData *crash )
|
||||
|
||||
static void RunCrashHandler( const CrashData *crash )
|
||||
{
|
||||
if( g_pCrashHandlerArgv0 == NULL )
|
||||
if( g_pCrashHandlerArgv0 == nullptr )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", nullptr );
|
||||
_exit( 1 );
|
||||
}
|
||||
|
||||
@@ -221,9 +221,9 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
struct sigaction sa;
|
||||
memset( &sa, 0, sizeof(sa) );
|
||||
sa.sa_handler = SIG_IGN;
|
||||
if( sigaction( SIGPIPE, &sa, NULL ) != 0 )
|
||||
if( sigaction( SIGPIPE, &sa, nullptr ) != 0 )
|
||||
{
|
||||
safe_print( fileno(stderr), "sigaction() failed: %s", strerror(errno), NULL );
|
||||
safe_print( fileno(stderr), "sigaction() failed: %s", strerror(errno), nullptr );
|
||||
/* non-fatal */
|
||||
}
|
||||
|
||||
@@ -237,22 +237,22 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
switch( crash->type )
|
||||
{
|
||||
case CrashData::SIGNAL:
|
||||
safe_print( fileno(stderr), "Fatal signal (", SignalName(crash->signal), ")", NULL );
|
||||
safe_print( fileno(stderr), "Fatal signal (", SignalName(crash->signal), ")", nullptr );
|
||||
break;
|
||||
|
||||
case CrashData::FORCE_CRASH:
|
||||
safe_print( fileno(stderr), "Crash handler failed: \"", crash->reason, "\"", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler failed: \"", crash->reason, "\"", nullptr );
|
||||
break;
|
||||
|
||||
default:
|
||||
safe_print( fileno(stderr), "Unexpected RunCrashHandler call (", itoa(crash->type), ")", NULL );
|
||||
safe_print( fileno(stderr), "Unexpected RunCrashHandler call (", itoa(crash->type), ")", nullptr );
|
||||
break;
|
||||
}
|
||||
|
||||
if( active == 1 )
|
||||
safe_print( fileno(stderr), " while still in the crash handler\n", NULL);
|
||||
safe_print( fileno(stderr), " while still in the crash handler\n", nullptr);
|
||||
else if( active == 2 )
|
||||
safe_print( fileno(stderr), " while in the crash handler child\n", NULL);
|
||||
safe_print( fileno(stderr), " while in the crash handler child\n", nullptr);
|
||||
|
||||
_exit( 1 );
|
||||
}
|
||||
@@ -267,14 +267,14 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
int fds[2];
|
||||
if( pipe(fds) != 0 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler pipe() failed: ", strerror(errno), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler pipe() failed: ", strerror(errno), "\n", nullptr );
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
pid_t childpid = fork();
|
||||
if( childpid == -1 )
|
||||
{
|
||||
safe_print( fileno(stderr), "Crash handler fork() failed: ", strerror(errno), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler fork() failed: ", strerror(errno), "\n", nullptr );
|
||||
_exit( 1 );
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
RageThread::ResumeAllThreads();
|
||||
|
||||
if( WIFSIGNALED(status) )
|
||||
safe_print( fileno(stderr), "Crash handler child exited with signal ", itoa(WTERMSIG(status)), "\n", NULL );
|
||||
safe_print( fileno(stderr), "Crash handler child exited with signal ", itoa(WTERMSIG(status)), "\n", nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ void CrashHandler::ForceCrash( const char *reason )
|
||||
strncpy( crash.reason, reason, sizeof(crash.reason) );
|
||||
crash.reason[ sizeof(crash.reason)-1 ] = 0;
|
||||
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, NULL );
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, nullptr );
|
||||
|
||||
RunCrashHandler( &crash );
|
||||
}
|
||||
@@ -352,7 +352,7 @@ void CrashHandler::ForceDeadlock( RString reason, uint64_t iID )
|
||||
|
||||
crash.type = CrashData::FORCE_CRASH;
|
||||
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, NULL );
|
||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, nullptr );
|
||||
|
||||
if( iID == GetInvalidThreadId() )
|
||||
{
|
||||
@@ -384,7 +384,7 @@ void CrashHandler::CrashSignalHandler( int signal, siginfo_t *si, const ucontext
|
||||
static volatile bool bInCrashSignalHandler = false;
|
||||
if( bInCrashSignalHandler )
|
||||
{
|
||||
safe_print( 2, "Fatal: crash from within the crash signal handler\n", NULL );
|
||||
safe_print( 2, "Fatal: crash from within the crash signal handler\n", nullptr );
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
bool child_read( int fd, void *p, int size );
|
||||
|
||||
const char *g_pCrashHandlerArgv0 = NULL;
|
||||
const char *g_pCrashHandlerArgv0 = nullptr;
|
||||
|
||||
|
||||
static void output_stack_trace( FILE *out, const void **BacktracePointers )
|
||||
@@ -153,7 +153,7 @@ static void child_process()
|
||||
|
||||
FD_ZERO( &rs );
|
||||
FD_SET( 3, &rs );
|
||||
int ret = select( 4, &rs, NULL, NULL, &timeout );
|
||||
int ret = select( 4, &rs, nullptr, nullptr, &timeout );
|
||||
|
||||
if( ret == 0 )
|
||||
{
|
||||
@@ -194,7 +194,7 @@ static void child_process()
|
||||
sCrashInfoPath += "/crashinfo.txt";
|
||||
|
||||
FILE *CrashDump = fopen( sCrashInfoPath, "w+" );
|
||||
if(CrashDump == NULL)
|
||||
if(CrashDump == nullptr)
|
||||
{
|
||||
fprintf( stderr, "Couldn't open " + sCrashInfoPath + ": %s\n", strerror(errno) );
|
||||
exit(1);
|
||||
@@ -271,7 +271,7 @@ static void child_process()
|
||||
/* stdout may have been inadvertently closed by the crash in the parent;
|
||||
* write to /dev/tty instead. */
|
||||
FILE *tty = fopen( "/dev/tty", "w" );
|
||||
if( tty == NULL )
|
||||
if( tty == nullptr )
|
||||
tty = stderr;
|
||||
|
||||
fputs( "\n"
|
||||
|
||||
@@ -59,7 +59,7 @@ SaveSignals::SaveSignals()
|
||||
for( int i = 0; signals[i] != -1; ++i )
|
||||
{
|
||||
struct sigaction sa;
|
||||
sigaction( signals[i], NULL, &sa );
|
||||
sigaction( signals[i], nullptr, &sa );
|
||||
old_handlers.push_back( sa );
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ SaveSignals::~SaveSignals()
|
||||
{
|
||||
/* Restore the old signal handlers. */
|
||||
for( unsigned i = 0; i < old_handlers.size(); ++i )
|
||||
sigaction( signals[i], &old_handlers[i], NULL );
|
||||
sigaction( signals[i], &old_handlers[i], nullptr );
|
||||
}
|
||||
|
||||
static void SigHandler( int signal, siginfo_t *si, void *ucp )
|
||||
@@ -88,7 +88,7 @@ static void SigHandler( int signal, siginfo_t *si, void *ucp )
|
||||
struct sigaction old;
|
||||
sigaction( signal, &sa, &old );
|
||||
raise( signal );
|
||||
sigaction( signal, &old, NULL );
|
||||
sigaction( signal, &old, nullptr );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,13 +117,13 @@ static void *CreateStack( int size )
|
||||
*
|
||||
* mmap entries always show up individually in /proc/#/maps. We could use posix_memalign as
|
||||
* a fallback, but we'd have to put a barrier page on both sides to guarantee that. */
|
||||
char *p = NULL;
|
||||
p = (char *) mmap( NULL, size+PageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
|
||||
char *p = nullptr;
|
||||
p = (char *) mmap( nullptr, size+PageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
|
||||
|
||||
if( p == (void *) -1 )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
// if( posix_memalign( (void**) &p, PageSize, RealSize ) != 0 )
|
||||
// return NULL;
|
||||
// return nullptr;
|
||||
|
||||
if( find_stack_direction() < 0 )
|
||||
{
|
||||
@@ -143,7 +143,7 @@ static void *CreateStack( int size )
|
||||
/* Hook up events to fatal signals, so we can clean up if we're killed. */
|
||||
void SignalHandler::OnClose( handler h )
|
||||
{
|
||||
if( saved_sigs == NULL )
|
||||
if( saved_sigs == nullptr )
|
||||
{
|
||||
saved_sigs = new SaveSignals;
|
||||
|
||||
@@ -158,27 +158,27 @@ void SignalHandler::OnClose( handler h )
|
||||
/* Allocate a separate signal stack. This makes the crash handler work
|
||||
* if we run out of stack space. */
|
||||
const int AltStackSize = 1024*64;
|
||||
void *p = NULL;
|
||||
void *p = nullptr;
|
||||
if( bUseAltSigStack )
|
||||
p = CreateStack( AltStackSize );
|
||||
|
||||
if( p != NULL )
|
||||
if( p != nullptr )
|
||||
{
|
||||
stack_t ss;
|
||||
ss.ss_sp = (char*)p; /* cast for Darwin */
|
||||
ss.ss_size = AltStackSize;
|
||||
ss.ss_flags = 0;
|
||||
if( sigaltstack( &ss, NULL ) == -1 )
|
||||
if( sigaltstack( &ss, nullptr ) == -1 )
|
||||
{
|
||||
LOG->Info( "sigaltstack failed: %s", strerror(errno) );
|
||||
p = NULL; /* no SA_ONSTACK */
|
||||
p = nullptr; /* no SA_ONSTACK */
|
||||
}
|
||||
}
|
||||
|
||||
struct sigaction sa;
|
||||
|
||||
sa.sa_flags = 0;
|
||||
if( p != NULL )
|
||||
if( p != nullptr )
|
||||
sa.sa_flags |= SA_ONSTACK;
|
||||
sa.sa_flags |= SA_NODEFER;
|
||||
sa.sa_flags |= SA_SIGINFO;
|
||||
@@ -187,11 +187,11 @@ void SignalHandler::OnClose( handler h )
|
||||
/* Set up our signal handlers. */
|
||||
sa.sa_sigaction = SigHandler;
|
||||
for( int i = 0; signals[i] != -1; ++i )
|
||||
sigaction( signals[i], &sa, NULL );
|
||||
sigaction( signals[i], &sa, nullptr );
|
||||
|
||||
/* Block SIGPIPE, so we get EPIPE. */
|
||||
sa.sa_handler = SIG_IGN;
|
||||
sigaction( SIGPIPE, &sa, NULL );
|
||||
sigaction( SIGPIPE, &sa, nullptr );
|
||||
}
|
||||
handlers.push_back(h);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <X11/extensions/dpms.h>
|
||||
|
||||
Display *X11Helper::Dpy = NULL;
|
||||
Display *X11Helper::Dpy = nullptr;
|
||||
Window X11Helper::Win = None;
|
||||
|
||||
static int ErrorCallback( Display*, XErrorEvent* );
|
||||
@@ -20,9 +20,9 @@ static bool dpms_state_at_startup= false;
|
||||
|
||||
bool X11Helper::OpenXConnection()
|
||||
{
|
||||
DEBUG_ASSERT( Dpy == NULL && Win == None );
|
||||
DEBUG_ASSERT( Dpy == nullptr && Win == None );
|
||||
Dpy = XOpenDisplay(0);
|
||||
if( Dpy == NULL )
|
||||
if( Dpy == nullptr )
|
||||
return false;
|
||||
|
||||
XSetIOErrorHandler( FatalCallback );
|
||||
@@ -65,10 +65,10 @@ void X11Helper::CloseXConnection()
|
||||
}
|
||||
}
|
||||
// The window should have been shut down
|
||||
DEBUG_ASSERT( Dpy != NULL );
|
||||
DEBUG_ASSERT( Dpy != nullptr );
|
||||
DEBUG_ASSERT( Win == None );
|
||||
XCloseDisplay( Dpy );
|
||||
Dpy = NULL;
|
||||
Dpy = nullptr;
|
||||
}
|
||||
|
||||
bool X11Helper::MakeWindow( Window &win, int screenNum, int depth, Visual *visual, int width, int height, bool overrideRedirect )
|
||||
@@ -103,7 +103,7 @@ bool X11Helper::MakeWindow( Window &win, int screenNum, int depth, Visual *visua
|
||||
return false;
|
||||
|
||||
XClassHint *hint = XAllocClassHint();
|
||||
if ( hint == NULL ) {
|
||||
if ( hint == nullptr ) {
|
||||
LOG->Warn("Could not set class hint for X11 Window");
|
||||
} else {
|
||||
hint->res_name = (char*)g_XWMName.Get().c_str();
|
||||
|
||||
@@ -5,9 +5,9 @@ AppInstance::AppInstance()
|
||||
{
|
||||
// Little trick to get an HINSTANCE of ourself without having access to the hwnd.
|
||||
TCHAR szFullAppPath[MAX_PATH];
|
||||
GetModuleFileName(NULL, szFullAppPath, MAX_PATH);
|
||||
GetModuleFileName(nullptr, szFullAppPath, MAX_PATH);
|
||||
h = LoadLibrary(szFullAppPath);
|
||||
/* h will be NULL if this fails. Most operations that take an HINSTANCE
|
||||
/* h will be nullptr if this fails. Most operations that take an HINSTANCE
|
||||
* will still work without one (but may be missing graphics); that's OK. */
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ int GetWin32CmdLine( char** &argv )
|
||||
{
|
||||
char *pCmdLine = GetCommandLine();
|
||||
int argc = 0;
|
||||
argv = NULL;
|
||||
argv = nullptr;
|
||||
|
||||
int i = 0;
|
||||
while( pCmdLine[i] )
|
||||
|
||||
@@ -23,7 +23,7 @@ static void SpliceProgramPath(char *buf, int bufsiz, const char *fn) {
|
||||
char tbuf[MAX_PATH];
|
||||
char *pszFile;
|
||||
|
||||
GetModuleFileName(NULL, tbuf, sizeof tbuf);
|
||||
GetModuleFileName(nullptr, tbuf, sizeof tbuf);
|
||||
GetFullPathName(tbuf, bufsiz, buf, &pszFile);
|
||||
strcpy(pszFile, fn);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ static const struct ExceptionLookup {
|
||||
{ EXCEPTION_INVALID_HANDLE, "Invalid handle" },
|
||||
{ EXCEPTION_STACK_OVERFLOW, "Stack overflow" },
|
||||
{ 0xe06d7363, "Unhandled Microsoft C++ Exception", },
|
||||
{ NULL },
|
||||
{ nullptr },
|
||||
};
|
||||
|
||||
static const char *LookupException( DWORD code )
|
||||
@@ -59,7 +59,7 @@ static const char *LookupException( DWORD code )
|
||||
if( exceptions[i].code == code )
|
||||
return exceptions[i].name;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static CrashInfo g_CrashInfo;
|
||||
@@ -68,13 +68,13 @@ static void GetReason( const EXCEPTION_RECORD *pRecord, CrashInfo *crash )
|
||||
// fill out bomb reason
|
||||
const char *reason = LookupException( pRecord->ExceptionCode );
|
||||
|
||||
if( reason == NULL )
|
||||
if( reason == nullptr )
|
||||
wsprintf( crash->m_CrashReason, "unknown exception 0x%08lx", pRecord->ExceptionCode );
|
||||
else
|
||||
strcpy( crash->m_CrashReason, reason );
|
||||
}
|
||||
|
||||
static HWND g_hForegroundWnd = NULL;
|
||||
static HWND g_hForegroundWnd = nullptr;
|
||||
void CrashHandler::SetForegroundWindow( HWND hWnd )
|
||||
{
|
||||
g_hForegroundWnd = hWnd;
|
||||
@@ -85,7 +85,7 @@ void WriteToChild( HANDLE hPipe, const void *pData, size_t iSize )
|
||||
while( iSize )
|
||||
{
|
||||
DWORD iActual;
|
||||
if( !WriteFile(hPipe, pData, iSize, &iActual, NULL) )
|
||||
if( !WriteFile(hPipe, pData, iSize, &iActual, nullptr) )
|
||||
return;
|
||||
iSize -= iActual;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ bool StartChild( HANDLE &hProcess, HANDLE &hToStdin, HANDLE &hFromStdout )
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.bInheritHandle = true;
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.lpSecurityDescriptor = nullptr;
|
||||
|
||||
CreatePipe( &si.hStdInput, &hToStdin, &sa, 0 );
|
||||
CreatePipe( &hFromStdout, &si.hStdOutput, &sa, 0 );
|
||||
@@ -115,19 +115,19 @@ bool StartChild( HANDLE &hProcess, HANDLE &hToStdin, HANDLE &hFromStdout )
|
||||
}
|
||||
|
||||
char szBuf[256] = "";
|
||||
GetModuleFileName( NULL, szBuf, MAX_PATH );
|
||||
GetModuleFileName( nullptr, szBuf, MAX_PATH );
|
||||
strcat( szBuf, " " );
|
||||
strcat( szBuf, CHILD_MAGIC_PARAMETER );
|
||||
|
||||
PROCESS_INFORMATION pi;
|
||||
int iRet = CreateProcess(
|
||||
NULL, // pointer to name of executable module
|
||||
nullptr, // pointer to name of executable module
|
||||
szBuf, // pointer to command line string
|
||||
NULL, // process security attributes
|
||||
NULL, // thread security attributes
|
||||
nullptr, // process security attributes
|
||||
nullptr, // thread security attributes
|
||||
true, // handle inheritance flag
|
||||
0, // creation flags
|
||||
NULL, // pointer to new environment block
|
||||
nullptr, // pointer to new environment block
|
||||
cwd, // pointer to current directory name
|
||||
&si, // pointer to STARTUPINFO
|
||||
&pi // pointer to PROCESS_INFORMATION
|
||||
@@ -156,19 +156,19 @@ static const char *CrashGetModuleBaseName(HMODULE hmod, char *pszBaseName)
|
||||
// XXX: It looks like nothing in here COULD throw an exception. Need to verify that.
|
||||
// __try {
|
||||
if( !GetModuleFileName(hmod, szPath1, sizeof(szPath1)) )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
char *pszFile;
|
||||
DWORD dw = GetFullPathName( szPath1, sizeof(szPath2), szPath2, &pszFile );
|
||||
|
||||
if( !dw || dw > sizeof(szPath2) )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
strcpy( pszBaseName, pszFile );
|
||||
|
||||
pszFile = pszBaseName;
|
||||
|
||||
char *period = NULL;
|
||||
char *period = nullptr;
|
||||
while( *pszFile++ )
|
||||
if( pszFile[-1]=='.' )
|
||||
period = pszFile-1;
|
||||
@@ -176,7 +176,7 @@ static const char *CrashGetModuleBaseName(HMODULE hmod, char *pszBaseName)
|
||||
if( period )
|
||||
*period = 0;
|
||||
// } __except(1) {
|
||||
// return NULL;
|
||||
// return nullptr;
|
||||
// }
|
||||
|
||||
return pszBaseName;
|
||||
@@ -222,7 +222,7 @@ void RunChild()
|
||||
// 4. Write RecentLogs.
|
||||
int cnt = 0;
|
||||
const TCHAR *ps[1024];
|
||||
while( cnt < 1024 && (ps[cnt] = RageLog::GetRecentLog( cnt )) != NULL )
|
||||
while( cnt < 1024 && (ps[cnt] = RageLog::GetRecentLog( cnt )) != nullptr )
|
||||
++cnt;
|
||||
|
||||
WriteToChild(hToStdin, &cnt, sizeof(cnt));
|
||||
@@ -254,7 +254,7 @@ void RunChild()
|
||||
* since GetModuleFileNameEx might not be available. Run the requests here. */
|
||||
HMODULE hMod;
|
||||
DWORD iActual;
|
||||
if( !ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, NULL) )
|
||||
if( !ReadFile( hFromStdout, &hMod, sizeof(hMod), &iActual, nullptr) )
|
||||
break;
|
||||
|
||||
TCHAR szName[MAX_PATH];
|
||||
@@ -301,8 +301,8 @@ static long MainExceptionHandler( EXCEPTION_POINTERS *pExc )
|
||||
/* If we get here, then we've been called recursively, which means we
|
||||
* crashed. If InHere is greater than 1, then we crashed after writing
|
||||
* the crash dump; say so. */
|
||||
SetUnhandledExceptionFilter(NULL);
|
||||
MessageBox( NULL,
|
||||
SetUnhandledExceptionFilter(nullptr);
|
||||
MessageBox( nullptr,
|
||||
InHere == 1?
|
||||
"The error reporting interface has crashed.\n":
|
||||
"The error reporting interface has crashed. However, crashinfo.txt was"
|
||||
@@ -333,7 +333,7 @@ static long MainExceptionHandler( EXCEPTION_POINTERS *pExc )
|
||||
/* Now things get more risky. If we're fullscreen, the window will obscure
|
||||
* the crash dialog. Try to hide the window. Things might blow up here; do
|
||||
* this after DoSave, so we always write a crash dump. */
|
||||
if( GetWindowThreadProcessId( g_hForegroundWnd, NULL ) == GetCurrentThreadId() )
|
||||
if( GetWindowThreadProcessId( g_hForegroundWnd, nullptr ) == GetCurrentThreadId() )
|
||||
{
|
||||
/* The thread that crashed was the thread that created the main window.
|
||||
* Hide the window. This will also restore the video mode, if necessary. */
|
||||
@@ -342,12 +342,12 @@ static long MainExceptionHandler( EXCEPTION_POINTERS *pExc )
|
||||
/* A different thread crashed. Simply kill all other windows. We can't
|
||||
* safely call ShowWindow; the main thread might be deadlocked. */
|
||||
RageThread::HaltAllThreads( true );
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
ChangeDisplaySettings( nullptr, 0 );
|
||||
}
|
||||
|
||||
InHere = false;
|
||||
|
||||
SetUnhandledExceptionFilter( NULL );
|
||||
SetUnhandledExceptionFilter(nullptr);
|
||||
|
||||
/* Forcibly terminate; if we keep going, we'll try to shut down threads and
|
||||
* do other things that may deadlock, which is confusing for users. */
|
||||
@@ -362,7 +362,7 @@ long __stdcall CrashHandler::ExceptionHandler( EXCEPTION_POINTERS *pExc )
|
||||
* Allocate a new stack, and run the exception handler in it, to increase
|
||||
* the chances of success. */
|
||||
int iSize = 1024*32;
|
||||
char *pStack = (char *) VirtualAlloc( NULL, iSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );
|
||||
char *pStack = (char *) VirtualAlloc( nullptr, iSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE );
|
||||
pStack += iSize;
|
||||
// FIXME: This will probably explode on x86-64
|
||||
#if defined(_MSC_VER)
|
||||
@@ -456,7 +456,7 @@ static bool PointsToValidCall( unsigned long ptr )
|
||||
|
||||
memset( buf, 0, sizeof(buf) );
|
||||
|
||||
while(len > 0 && !ReadProcessMemory(GetCurrentProcess(), (void *)(ptr-len), buf+7-len, len, NULL))
|
||||
while(len > 0 && !ReadProcessMemory(GetCurrentProcess(), (void *)(ptr-len), buf+7-len, len, nullptr))
|
||||
--len;
|
||||
|
||||
return IsValidCall(buf+7, len);
|
||||
@@ -473,7 +473,7 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
|
||||
* due to stack corruption, we might not be able to get any frames from the
|
||||
* stack. Pull it out of pContext->Eip, which is always valid, and then
|
||||
* discard the first stack frame if it's the same. */
|
||||
if( buf+1 != pLast && pContext->Eip != NULL )
|
||||
if( buf+1 != pLast && pContext->Eip != 0 )
|
||||
{
|
||||
*buf = (void *) pContext->Eip;
|
||||
++buf;
|
||||
@@ -485,7 +485,7 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
|
||||
LDT_ENTRY sel;
|
||||
if( !GetThreadSelectorEntry( hThread, pContext->SegFs, &sel ) )
|
||||
{
|
||||
*buf = NULL;
|
||||
*buf = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -532,16 +532,15 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
|
||||
break;
|
||||
|
||||
lpAddr += 4;
|
||||
} while( ReadProcessMemory(hProcess, lpAddr-4, &data, 4, NULL));
|
||||
} while( ReadProcessMemory(hProcess, lpAddr-4, &data, 4, nullptr));
|
||||
|
||||
*buf = NULL;
|
||||
*buf = nullptr;
|
||||
}
|
||||
|
||||
// Trigger the crash handler. This works even in the debugger.
|
||||
static void NORETURN debug_crash()
|
||||
{
|
||||
// __try {
|
||||
#if defined(__MSC_VER)
|
||||
__try {
|
||||
__asm xor ebx,ebx
|
||||
__asm mov eax,dword ptr [ebx]
|
||||
// __asm mov dword ptr [ebx],eax
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace VDDebugInfo
|
||||
{
|
||||
struct Context
|
||||
{
|
||||
Context() { pRVAHeap=NULL; }
|
||||
bool Loaded() const { return pRVAHeap != NULL; }
|
||||
Context() { pRVAHeap=nullptr; }
|
||||
bool Loaded() const { return pRVAHeap != nullptr; }
|
||||
RString sRawBlock;
|
||||
|
||||
int nBuildNumber;
|
||||
@@ -59,7 +59,7 @@ namespace VDDebugInfo
|
||||
|
||||
static void GetVDIPath( char *buf, int bufsiz )
|
||||
{
|
||||
GetModuleFileName( NULL, buf, bufsiz );
|
||||
GetModuleFileName( nullptr, buf, bufsiz );
|
||||
buf[bufsiz-5] = 0;
|
||||
char *p = strrchr( buf, '.' );
|
||||
if( p )
|
||||
@@ -86,7 +86,7 @@ namespace VDDebugInfo
|
||||
|
||||
const unsigned char *src = (const unsigned char *) pctx->sRawBlock.data();
|
||||
|
||||
pctx->pRVAHeap = NULL;
|
||||
pctx->pRVAHeap = nullptr;
|
||||
|
||||
static const char *header = "symbolic debug information";
|
||||
if( memcmp(src, header, strlen(header)) )
|
||||
@@ -121,11 +121,11 @@ namespace VDDebugInfo
|
||||
return true;
|
||||
|
||||
pctx->sRawBlock = RString();
|
||||
pctx->pRVAHeap = NULL;
|
||||
pctx->pRVAHeap = nullptr;
|
||||
GetVDIPath( pctx->sFilename, ARRAYLEN(pctx->sFilename) );
|
||||
pctx->sError = RString();
|
||||
|
||||
HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr );
|
||||
if( h == INVALID_HANDLE_VALUE )
|
||||
{
|
||||
pctx->sError = werr_ssprintf( GetLastError(), "CreateFile failed" );
|
||||
@@ -133,7 +133,7 @@ namespace VDDebugInfo
|
||||
}
|
||||
|
||||
do {
|
||||
DWORD dwFileSize = GetFileSize( h, NULL );
|
||||
DWORD dwFileSize = GetFileSize( h, nullptr );
|
||||
if( dwFileSize == INVALID_FILE_SIZE )
|
||||
break;
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace VDDebugInfo
|
||||
std::fill(buffer, buffer + dwFileSize + 1, '\0' );
|
||||
|
||||
DWORD dwActual;
|
||||
int iRet = ReadFile(h, buffer, dwFileSize, &dwActual, NULL);
|
||||
int iRet = ReadFile(h, buffer, dwFileSize, &dwActual, nullptr);
|
||||
CloseHandle(h);
|
||||
pctx->sRawBlock = buffer;
|
||||
delete[] buffer;
|
||||
@@ -268,7 +268,7 @@ namespace SymbolLookup
|
||||
{
|
||||
SymSetOptions( SYMOPT_UNDNAME | SYMOPT_DEFERRED_LOADS );
|
||||
|
||||
if( !SymInitialize(g_hParent, NULL, TRUE) )
|
||||
if( !SymInitialize(g_hParent, nullptr, TRUE) )
|
||||
return false;
|
||||
|
||||
bInitted = true;
|
||||
@@ -288,7 +288,7 @@ namespace SymbolLookup
|
||||
pSymbol->MaxNameLen = sizeof(buffer) - sizeof(SYMBOL_INFO) + 1;
|
||||
|
||||
if( !SymFromAddr(g_hParent, ptr, &disp, pSymbol) )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return pSymbol;
|
||||
}
|
||||
@@ -394,7 +394,7 @@ namespace
|
||||
RString SpliceProgramPath( RString fn )
|
||||
{
|
||||
char szBuf[MAX_PATH];
|
||||
GetModuleFileName( NULL, szBuf, sizeof(szBuf) );
|
||||
GetModuleFileName( nullptr, szBuf, sizeof(szBuf) );
|
||||
|
||||
char szModName[MAX_PATH];
|
||||
char *pszFile;
|
||||
@@ -491,7 +491,7 @@ static void DoSave( const RString &sReport )
|
||||
|
||||
SetFileAttributes( sName, FILE_ATTRIBUTE_NORMAL );
|
||||
FILE *pFile = fopen( sName, "w+" );
|
||||
if( pFile == NULL )
|
||||
if( pFile == nullptr )
|
||||
return;
|
||||
fprintf( pFile, "%s", sReport.c_str() );
|
||||
|
||||
@@ -659,7 +659,7 @@ CrashDialog::CrashDialog( const RString &sCrashReport, const CompleteCrashData &
|
||||
m_CrashData( CrashData )
|
||||
{
|
||||
LoadLocalizedStrings();
|
||||
m_pPost = NULL;
|
||||
m_pPost = nullptr;
|
||||
}
|
||||
|
||||
CrashDialog::~CrashDialog()
|
||||
@@ -692,7 +692,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
HDC hdc = (HDC)wParam;
|
||||
HWND hwndStatic = (HWND)lParam;
|
||||
HBRUSH hbr = NULL;
|
||||
HBRUSH hbr = nullptr;
|
||||
|
||||
// TODO: Change any attributes of the DC here
|
||||
switch( GetDlgCtrlID(hwndStatic) )
|
||||
@@ -713,7 +713,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
case IDC_BUTTON_CLOSE:
|
||||
if( m_pPost != NULL )
|
||||
if( m_pPost != nullptr )
|
||||
{
|
||||
// Cancel reporting, and revert the dialog as if "report" had not been pressed.
|
||||
m_pPost->Cancel();
|
||||
@@ -734,7 +734,7 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
RString sLogPath;
|
||||
FILE *pFile = fopen( SpliceProgramPath("../Portable.ini"), "r" );
|
||||
if(pFile != NULL)
|
||||
if(pFile != nullptr)
|
||||
{
|
||||
sLogPath = SpliceProgramPath("../Logs/log.txt");
|
||||
fclose( pFile );
|
||||
@@ -742,11 +742,11 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
else
|
||||
sLogPath = SpecialDirs::GetAppDataDir() + PRODUCT_ID +"/Logs/log.txt";
|
||||
|
||||
ShellExecute( NULL, "open", sLogPath, "", "", SW_SHOWNORMAL );
|
||||
ShellExecute( nullptr, "open", sLogPath, "", "", SW_SHOWNORMAL );
|
||||
}
|
||||
break;
|
||||
case IDC_CRASH_SAVE:
|
||||
ShellExecute( NULL, "open", SpliceProgramPath("../crashinfo.txt"), "", "", SW_SHOWNORMAL );
|
||||
ShellExecute( nullptr, "open", SpliceProgramPath("../crashinfo.txt"), "", "", SW_SHOWNORMAL );
|
||||
return TRUE;
|
||||
case IDC_BUTTON_RESTART:
|
||||
Win32RestartProgram();
|
||||
@@ -781,13 +781,13 @@ BOOL CrashDialog::HandleMessage( UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
|
||||
m_pPost->Start( CRASH_REPORT_HOST, CRASH_REPORT_PORT, CRASH_REPORT_PATH );
|
||||
|
||||
SetTimer( hDlg, 0, 100, NULL );
|
||||
SetTimer( hDlg, 0, 100, nullptr );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WM_TIMER:
|
||||
{
|
||||
if( m_pPost == NULL )
|
||||
if( m_pPost == nullptr )
|
||||
break;
|
||||
|
||||
float fProgress = m_pPost->GetProgress();
|
||||
@@ -875,7 +875,7 @@ void ChildProcess()
|
||||
|
||||
// Now that we've done that, the process is gone. Don't use g_hParent.
|
||||
CloseHandle( SymbolLookup::g_hParent );
|
||||
SymbolLookup::g_hParent = NULL;
|
||||
SymbolLookup::g_hParent = nullptr;
|
||||
|
||||
CrashDialog cd( sCrashReport, Data );
|
||||
#if defined(AUTOMATED_CRASH_REPORTS)
|
||||
|
||||
@@ -18,7 +18,7 @@ struct CrashInfo
|
||||
m_CrashReason[0] = 0;
|
||||
memset( m_AlternateThreadBacktrace, 0, sizeof(m_AlternateThreadBacktrace) );
|
||||
memset( m_AlternateThreadName, 0, sizeof(m_AlternateThreadName) );
|
||||
m_BacktracePointers[0] = NULL;
|
||||
m_BacktracePointers[0] = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "RageThreads.h"
|
||||
#include "RageTimer.h"
|
||||
#include "RageUtil.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#include <windows.h>
|
||||
@@ -158,7 +158,7 @@ NetworkStream *CreateNetworkStream()
|
||||
WSADATA WSAData;
|
||||
WORD iVersionRequested = MAKEWORD(2,0);
|
||||
if( WSAStartup(iVersionRequested, &WSAData) != 0 )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new NetworkStream_Win32;
|
||||
@@ -170,11 +170,11 @@ NetworkStream_Win32::NetworkStream_Win32():
|
||||
{
|
||||
m_iPort = -1;
|
||||
m_State = STATE_IDLE;
|
||||
m_Socket = NULL;
|
||||
m_Socket = nullptr;
|
||||
#if defined(WINDOWS)
|
||||
m_hResolve = NULL;
|
||||
m_hResolveHwnd = NULL;
|
||||
m_hCompletionEvent = CreateEvent( NULL, true, false, NULL );
|
||||
m_hResolve = nullptr;
|
||||
m_hResolveHwnd = nullptr;
|
||||
m_hCompletionEvent = CreateEvent( nullptr, true, false, nullptr );
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -355,7 +355,7 @@ void NetworkStream_Win32::Open( const RString &sHost, int iPort, ConnectionType
|
||||
m_iPort = iPort;
|
||||
|
||||
// Look up the hostname.
|
||||
hostent *pHost = NULL;
|
||||
hostent *pHost = nullptr;
|
||||
char pBuf[MAXGETHOSTSTRUCT];
|
||||
{
|
||||
pHost = (hostent *) pBuf;
|
||||
@@ -374,8 +374,8 @@ void NetworkStream_Win32::Open( const RString &sHost, int iPort, ConnectionType
|
||||
mw.Run();
|
||||
|
||||
m_Mutex.Lock();
|
||||
m_hResolve = NULL;
|
||||
m_hResolveHwnd = NULL;
|
||||
m_hResolve = nullptr;
|
||||
m_hResolveHwnd = nullptr;
|
||||
if( m_State == STATE_CANCELLED )
|
||||
{
|
||||
m_Mutex.Unlock();
|
||||
@@ -475,7 +475,7 @@ void NetworkStream_Win32::Cancel()
|
||||
m_State = STATE_CANCELLED;
|
||||
|
||||
// If resolving, abort the resolve.
|
||||
if( m_hResolve != NULL )
|
||||
if( m_hResolve != nullptr )
|
||||
{
|
||||
/* When we cancel the request, no message at all will be sent to the window,
|
||||
* so we need to do it ourself to inform it that it was cancelled. Be sure
|
||||
@@ -588,18 +588,18 @@ void NetworkPostData::CreateMimeData( const map<RString,RString> &mapNameToData,
|
||||
while(1)
|
||||
{
|
||||
sMimeBoundaryOut = ssprintf( "--%08i", rand() );
|
||||
FOREACHM_CONST( RString, RString, mapNameToData, d )
|
||||
if( d->second.find(sMimeBoundaryOut) != RString::npos )
|
||||
for (auto const &d : mapNameToData)
|
||||
if( d.second.find(sMimeBoundaryOut) != RString::npos )
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
FOREACHM_CONST( RString, RString, mapNameToData, d )
|
||||
for (auto const &d : mapNameToData)
|
||||
{
|
||||
sOut += "--" + sMimeBoundaryOut + "\r\n";
|
||||
sOut += ssprintf( "Content-Disposition: form-data; name=\"%s\"\r\n", d->first.c_str() );
|
||||
sOut += ssprintf( "Content-Disposition: form-data; name=\"%s\"\r\n", d.first.c_str() );
|
||||
sOut += "\r\n";
|
||||
sOut += d->second;
|
||||
sOut += d.second;
|
||||
sOut += "\r\n";
|
||||
}
|
||||
if( sOut.size() )
|
||||
|
||||
+108
-108
@@ -1,108 +1,108 @@
|
||||
#include "global.h"
|
||||
#include "DialogUtil.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
|
||||
// Create*Font copied from MFC's CFont
|
||||
|
||||
// pLogFont->nHeight is interpreted as PointSize * 10
|
||||
static HFONT CreatePointFontIndirect(const LOGFONT* lpLogFont)
|
||||
{
|
||||
HDC hDC = ::GetDC(NULL);
|
||||
|
||||
// convert nPointSize to logical units based on pDC
|
||||
LOGFONT logFont = *lpLogFont;
|
||||
POINT pt;
|
||||
pt.y = ::GetDeviceCaps(hDC, LOGPIXELSY) * logFont.lfHeight;
|
||||
pt.y /= 720; // 72 points/inch * 10 decipoints/point
|
||||
pt.x = 0;
|
||||
::DPtoLP(hDC, &pt, 1);
|
||||
POINT ptOrg = { 0, 0 };
|
||||
::DPtoLP(hDC, &ptOrg, 1);
|
||||
logFont.lfHeight = -abs(pt.y - ptOrg.y);
|
||||
|
||||
ReleaseDC(NULL, hDC);
|
||||
|
||||
return ::CreateFontIndirect(&logFont);
|
||||
}
|
||||
|
||||
// nPointSize is actually scaled 10x
|
||||
static HFONT CreatePointFont(int nPointSize, LPCTSTR lpszFaceName)
|
||||
{
|
||||
ASSERT(lpszFaceName != NULL);
|
||||
|
||||
LOGFONT logFont;
|
||||
memset(&logFont, 0, sizeof(LOGFONT));
|
||||
logFont.lfCharSet = DEFAULT_CHARSET;
|
||||
logFont.lfHeight = nPointSize;
|
||||
lstrcpyn(logFont.lfFaceName, lpszFaceName, strlen(logFont.lfFaceName));
|
||||
|
||||
return ::CreatePointFontIndirect(&logFont);
|
||||
}
|
||||
|
||||
void DialogUtil::SetHeaderFont( HWND hdlg, int nID )
|
||||
{
|
||||
ASSERT( hdlg != NULL );
|
||||
|
||||
HWND hControl = ::GetDlgItem( hdlg, nID );
|
||||
ASSERT( hControl != NULL );
|
||||
|
||||
// TODO: Fix font leak
|
||||
const int FONT_POINTS = 16;
|
||||
HFONT hfont = CreatePointFont( FONT_POINTS*10, "Arial Black" );
|
||||
::SendMessage( hControl, WM_SETFONT, (WPARAM)hfont, TRUE );
|
||||
}
|
||||
|
||||
void DialogUtil::LocalizeDialogAndContents( HWND hdlg )
|
||||
{
|
||||
ASSERT( THEME != NULL );
|
||||
|
||||
const int LARGE_STRING = 256;
|
||||
char szTemp[LARGE_STRING] = "";
|
||||
RString sGroup;
|
||||
|
||||
{
|
||||
::GetWindowText( hdlg, szTemp, ARRAYLEN(szTemp) );
|
||||
RString s = szTemp;
|
||||
sGroup = "Dialog-"+s;
|
||||
s = THEME->GetString( sGroup, s );
|
||||
::SetWindowText( hdlg, ConvertUTF8ToACP(s).c_str() );
|
||||
}
|
||||
|
||||
for( HWND hwndChild = ::GetTopWindow(hdlg); hwndChild != NULL; hwndChild = ::GetNextWindow(hwndChild,GW_HWNDNEXT) )
|
||||
{
|
||||
::GetWindowText( hwndChild, szTemp, ARRAYLEN(szTemp) );
|
||||
RString s = szTemp;
|
||||
if( s.empty() )
|
||||
continue;
|
||||
s = THEME->GetString( sGroup, s );
|
||||
::SetWindowText( hwndChild, ConvertUTF8ToACP(s).c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "DialogUtil.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "archutils/Win32/ErrorStrings.h"
|
||||
|
||||
// Create*Font copied from MFC's CFont
|
||||
|
||||
// pLogFont->nHeight is interpreted as PointSize * 10
|
||||
static HFONT CreatePointFontIndirect(const LOGFONT* lpLogFont)
|
||||
{
|
||||
HDC hDC = ::GetDC(nullptr);
|
||||
|
||||
// convert nPointSize to logical units based on pDC
|
||||
LOGFONT logFont = *lpLogFont;
|
||||
POINT pt;
|
||||
pt.y = ::GetDeviceCaps(hDC, LOGPIXELSY) * logFont.lfHeight;
|
||||
pt.y /= 720; // 72 points/inch * 10 decipoints/point
|
||||
pt.x = 0;
|
||||
::DPtoLP(hDC, &pt, 1);
|
||||
POINT ptOrg = { 0, 0 };
|
||||
::DPtoLP(hDC, &ptOrg, 1);
|
||||
logFont.lfHeight = -abs(pt.y - ptOrg.y);
|
||||
|
||||
ReleaseDC(nullptr, hDC);
|
||||
|
||||
return ::CreateFontIndirect(&logFont);
|
||||
}
|
||||
|
||||
// nPointSize is actually scaled 10x
|
||||
static HFONT CreatePointFont(int nPointSize, LPCTSTR lpszFaceName)
|
||||
{
|
||||
ASSERT(lpszFaceName != nullptr);
|
||||
|
||||
LOGFONT logFont;
|
||||
memset(&logFont, 0, sizeof(LOGFONT));
|
||||
logFont.lfCharSet = DEFAULT_CHARSET;
|
||||
logFont.lfHeight = nPointSize;
|
||||
lstrcpyn(logFont.lfFaceName, lpszFaceName, strlen(logFont.lfFaceName));
|
||||
|
||||
return ::CreatePointFontIndirect(&logFont);
|
||||
}
|
||||
|
||||
void DialogUtil::SetHeaderFont( HWND hdlg, int nID )
|
||||
{
|
||||
ASSERT( hdlg != nullptr );
|
||||
|
||||
HWND hControl = ::GetDlgItem( hdlg, nID );
|
||||
ASSERT( hControl != nullptr );
|
||||
|
||||
// TODO: Fix font leak
|
||||
const int FONT_POINTS = 16;
|
||||
HFONT hfont = CreatePointFont( FONT_POINTS*10, "Arial Black" );
|
||||
::SendMessage( hControl, WM_SETFONT, (WPARAM)hfont, TRUE );
|
||||
}
|
||||
|
||||
void DialogUtil::LocalizeDialogAndContents( HWND hdlg )
|
||||
{
|
||||
ASSERT( THEME != nullptr );
|
||||
|
||||
const int LARGE_STRING = 256;
|
||||
char szTemp[LARGE_STRING] = "";
|
||||
RString sGroup;
|
||||
|
||||
{
|
||||
::GetWindowText( hdlg, szTemp, ARRAYLEN(szTemp) );
|
||||
RString s = szTemp;
|
||||
sGroup = "Dialog-"+s;
|
||||
s = THEME->GetString( sGroup, s );
|
||||
::SetWindowText( hdlg, ConvertUTF8ToACP(s).c_str() );
|
||||
}
|
||||
|
||||
for( HWND hwndChild = ::GetTopWindow(hdlg); hwndChild != nullptr; hwndChild = ::GetNextWindow(hwndChild,GW_HWNDNEXT) )
|
||||
{
|
||||
::GetWindowText( hwndChild, szTemp, ARRAYLEN(szTemp) );
|
||||
RString s = szTemp;
|
||||
if( s.empty() )
|
||||
continue;
|
||||
s = THEME->GetString( sGroup, s );
|
||||
::SetWindowText( hwndChild, ConvertUTF8ToACP(s).c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (c) 2002-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ RString werr_ssprintf( int err, const char *fmt, ... )
|
||||
{
|
||||
char buf[1024] = "";
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
0, err, 0, buf, sizeof(buf), NULL);
|
||||
0, err, 0, buf, sizeof(buf), nullptr);
|
||||
|
||||
// Why is FormatMessage returning text ending with \r\n? (who? -aj)
|
||||
// Perhaps it's because you're on Windows, where newlines are \r\n. -aj
|
||||
@@ -31,13 +31,13 @@ RString ConvertWstringToCodepage( wstring s, int iCodePage )
|
||||
return RString();
|
||||
|
||||
int iBytes = WideCharToMultiByte( iCodePage, 0, s.data(), s.size(),
|
||||
NULL, 0, NULL, FALSE );
|
||||
nullptr, 0, nullptr, FALSE );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "WideCharToMultiByte" ).c_str() );
|
||||
|
||||
char * buf = new char[iBytes + 1];
|
||||
std::fill(buf, buf + iBytes + 1, '\0');
|
||||
WideCharToMultiByte( CP_ACP, 0, s.data(), s.size(),
|
||||
buf, iBytes, NULL, FALSE );
|
||||
buf, iBytes, nullptr, FALSE );
|
||||
RString ret( buf );
|
||||
delete[] buf;
|
||||
return ret;
|
||||
@@ -53,7 +53,7 @@ wstring ConvertCodepageToWString( RString s, int iCodePage )
|
||||
if( s.empty() )
|
||||
return wstring();
|
||||
|
||||
int iBytes = MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), NULL, 0 );
|
||||
int iBytes = MultiByteToWideChar( iCodePage, 0, s.data(), s.size(), nullptr, 0 );
|
||||
ASSERT_M( iBytes > 0, werr_ssprintf( GetLastError(), "MultiByteToWideChar" ).c_str() );
|
||||
|
||||
wchar_t *pTemp = new wchar_t[iBytes];
|
||||
|
||||
@@ -22,7 +22,7 @@ bool GetFileVersion( RString sFile, RString &sOut )
|
||||
|
||||
RString VersionBuffer( iSize, ' ' );
|
||||
// Also VC6:
|
||||
if( !GetFileVersionInfo( const_cast<char *>(sFile.c_str()), NULL, iSize, const_cast<char *>(VersionBuffer.c_str()) ) )
|
||||
if( !GetFileVersionInfo( const_cast<char *>(sFile.c_str()), nullptr, iSize, const_cast<char *>(VersionBuffer.c_str()) ) )
|
||||
break;
|
||||
|
||||
WORD *iTrans;
|
||||
@@ -73,7 +73,7 @@ RString FindSystemFile( RString sFile )
|
||||
"/system/",
|
||||
"/system/drivers/",
|
||||
"/",
|
||||
NULL
|
||||
nullptr
|
||||
};
|
||||
|
||||
for( int i = 0; szPaths[i]; ++i )
|
||||
@@ -95,7 +95,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
|
||||
* kernel32.lib functions. */
|
||||
do {
|
||||
HANDLE hSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, iProcessID );
|
||||
if( hSnap == NULL )
|
||||
if( hSnap == nullptr )
|
||||
{
|
||||
sName = werr_ssprintf( GetLastError(), "CreateToolhelp32Snapshot" );
|
||||
break;
|
||||
@@ -118,9 +118,9 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
|
||||
|
||||
// This method only works in NT/2K/XP.
|
||||
do {
|
||||
static HINSTANCE hPSApi = NULL;
|
||||
static HINSTANCE hPSApi = nullptr;
|
||||
typedef DWORD (WINAPI* pfnGetProcessImageFileNameA)(HANDLE hProcess, LPSTR lpImageFileName, DWORD nSize);
|
||||
static pfnGetProcessImageFileNameA pGetProcessImageFileName = NULL;
|
||||
static pfnGetProcessImageFileNameA pGetProcessImageFileName = nullptr;
|
||||
static bool bTried = false;
|
||||
|
||||
if( !bTried )
|
||||
@@ -128,7 +128,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
|
||||
bTried = true;
|
||||
|
||||
hPSApi = LoadLibrary("psapi.dll");
|
||||
if( hPSApi == NULL )
|
||||
if( hPSApi == nullptr )
|
||||
{
|
||||
sName = werr_ssprintf( GetLastError(), "LoadLibrary" );
|
||||
break;
|
||||
@@ -136,7 +136,7 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
|
||||
else
|
||||
{
|
||||
pGetProcessImageFileName = (pfnGetProcessImageFileNameA) GetProcAddress( hPSApi, "GetProcessImageFileNameA" );
|
||||
if( pGetProcessImageFileName == NULL )
|
||||
if( pGetProcessImageFileName == nullptr )
|
||||
{
|
||||
sName = werr_ssprintf( GetLastError(), "GetProcAddress" );
|
||||
break;
|
||||
@@ -144,10 +144,10 @@ bool GetProcessFileName( uint32_t iProcessID, RString &sName )
|
||||
}
|
||||
}
|
||||
|
||||
if( pGetProcessImageFileName != NULL )
|
||||
if( pGetProcessImageFileName != nullptr )
|
||||
{
|
||||
HANDLE hProc = OpenProcess( PROCESS_VM_READ|PROCESS_QUERY_INFORMATION, NULL, iProcessID );
|
||||
if( hProc == NULL )
|
||||
HANDLE hProc = OpenProcess( PROCESS_VM_READ|PROCESS_QUERY_INFORMATION, nullptr, iProcessID );
|
||||
if( hProc == nullptr )
|
||||
{
|
||||
sName = werr_ssprintf( GetLastError(), "OpenProcess" );
|
||||
break;
|
||||
|
||||
@@ -25,7 +25,7 @@ static LONG GetRegKey( HKEY key, RString subkey, LPTSTR retdata )
|
||||
bool GotoURL( RString sUrl )
|
||||
{
|
||||
// First try ShellExecute()
|
||||
int iRet = (int) ShellExecute( NULL, "open", sUrl, NULL, NULL, SW_SHOWDEFAULT );
|
||||
int iRet = (int) ShellExecute( nullptr, "open", sUrl, nullptr, nullptr, SW_SHOWDEFAULT );
|
||||
|
||||
// If it failed, get the .htm regkey and lookup the program
|
||||
if( iRet > 32 )
|
||||
@@ -41,11 +41,11 @@ bool GotoURL( RString sUrl )
|
||||
return false;
|
||||
|
||||
char *szPos = strstr( key, "\"%1\"" );
|
||||
if( szPos == NULL )
|
||||
if( szPos == nullptr )
|
||||
{
|
||||
// No quotes found. Check for %1 without quotes
|
||||
szPos = strstr( key, "%1" );
|
||||
if( szPos == NULL )
|
||||
if( szPos == nullptr )
|
||||
szPos = key+lstrlen(key)-1; // No parameter.
|
||||
else
|
||||
*szPos = '\0'; // Remove the parameter
|
||||
|
||||
@@ -23,7 +23,7 @@ static HDC g_HDC;
|
||||
static VideoModeParams g_CurrentParams;
|
||||
static bool g_bResolutionChanged = false;
|
||||
static bool g_bHasFocus = true;
|
||||
static HICON g_hIcon = NULL;
|
||||
static HICON g_hIcon = nullptr;
|
||||
static bool m_bWideWindowClass;
|
||||
static bool g_bD3D = false;
|
||||
|
||||
@@ -36,8 +36,8 @@ static UINT g_iQueryCancelAutoPlayMessage = 0;
|
||||
static RString GetNewWindow()
|
||||
{
|
||||
HWND h = GetForegroundWindow();
|
||||
if( h == NULL )
|
||||
return "(NULL)";
|
||||
if( h == nullptr )
|
||||
return "(nullptr)";
|
||||
|
||||
DWORD iProcessID;
|
||||
GetWindowThreadProcessId( h, &iProcessID );
|
||||
@@ -92,7 +92,7 @@ static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wPar
|
||||
}
|
||||
else if( !g_bHasFocus && bHadFocus )
|
||||
{
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
ChangeDisplaySettings( nullptr, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ static LRESULT CALLBACK GraphicsWindow_WndProc( HWND hWnd, UINT msg, WPARAM wPar
|
||||
case WM_SETCURSOR:
|
||||
if( !g_CurrentParams.windowed )
|
||||
{
|
||||
SetCursor( NULL );
|
||||
SetCursor(nullptr);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@@ -190,7 +190,7 @@ static void AdjustVideoModeParams( VideoModeParams &p )
|
||||
DEVMODE dm;
|
||||
ZERO( dm );
|
||||
dm.dmSize = sizeof(dm);
|
||||
if( !EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm) )
|
||||
if( !EnumDisplaySettings(nullptr, ENUM_CURRENT_SETTINGS, &dm) )
|
||||
{
|
||||
p.rate = 60;
|
||||
LOG->Warn( "%s", werr_ssprintf(GetLastError(), "EnumDisplaySettings failed").c_str() );
|
||||
@@ -226,7 +226,7 @@ RString GraphicsWindow::SetScreenMode( const VideoModeParams &p )
|
||||
if( p.windowed )
|
||||
{
|
||||
// We're going windowed. If we were previously fullscreen, reset.
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
ChangeDisplaySettings( nullptr, 0 );
|
||||
|
||||
return RString();
|
||||
}
|
||||
@@ -244,7 +244,7 @@ RString GraphicsWindow::SetScreenMode( const VideoModeParams &p )
|
||||
DevMode.dmDisplayFrequency = p.rate;
|
||||
DevMode.dmFields |= DM_DISPLAYFREQUENCY;
|
||||
}
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
ChangeDisplaySettings( nullptr, 0 );
|
||||
|
||||
int ret = ChangeDisplaySettings( &DevMode, CDS_FULLSCREEN );
|
||||
if( ret != DISP_CHANGE_SUCCESSFUL && (DevMode.dmFields & DM_DISPLAYFREQUENCY) )
|
||||
@@ -278,20 +278,20 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
// Adjust g_CurrentParams to reflect the actual display settings.
|
||||
AdjustVideoModeParams( g_CurrentParams );
|
||||
|
||||
if( g_hWndMain == NULL || bForceRecreateWindow )
|
||||
if( g_hWndMain == nullptr || bForceRecreateWindow )
|
||||
{
|
||||
int iWindowStyle = GetWindowStyle( p.windowed );
|
||||
|
||||
AppInstance inst;
|
||||
HWND hWnd = CreateWindow( g_sClassName, "app", iWindowStyle,
|
||||
0, 0, 0, 0, NULL, NULL, inst, NULL );
|
||||
if( hWnd == NULL )
|
||||
0, 0, 0, 0, nullptr, nullptr, inst, nullptr );
|
||||
if( hWnd == nullptr )
|
||||
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "CreateWindow" ).c_str() );
|
||||
|
||||
/* If an old window exists, transfer focus to the new window before
|
||||
* deleting it, or some other window may temporarily get focus, which
|
||||
* can cause it to be resized. */
|
||||
if( g_hWndMain != NULL )
|
||||
if( g_hWndMain != nullptr )
|
||||
{
|
||||
// While we change to the new window, don't do ChangeDisplaySettings in WM_ACTIVATE.
|
||||
g_bRecreatingVideoMode = true;
|
||||
@@ -319,14 +319,14 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
} while(0);
|
||||
|
||||
// Update the window icon.
|
||||
if( g_hIcon != NULL )
|
||||
if( g_hIcon != nullptr )
|
||||
{
|
||||
SetClassLong( g_hWndMain, GCL_HICON, (LONG) LoadIcon(NULL,IDI_APPLICATION) );
|
||||
SetClassLong( g_hWndMain, GCL_HICON, (LONG) LoadIcon(nullptr,IDI_APPLICATION) );
|
||||
DestroyIcon( g_hIcon );
|
||||
g_hIcon = NULL;
|
||||
g_hIcon = nullptr;
|
||||
}
|
||||
g_hIcon = IconFromFile( p.sIconFile );
|
||||
if( g_hIcon != NULL )
|
||||
if( g_hIcon != nullptr )
|
||||
SetClassLong( g_hWndMain, GCL_HICON, (LONG) g_hIcon );
|
||||
|
||||
/* The window style may change as a result of switching to or from fullscreen;
|
||||
@@ -364,9 +364,9 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
* If we don't do this, then starting up in a D3D fullscreen window may
|
||||
* cause all other windows on the system to be resized. */
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
}
|
||||
@@ -374,36 +374,36 @@ void GraphicsWindow::CreateGraphicsWindow( const VideoModeParams &p, bool bForce
|
||||
/** @brief Shut down the window, but don't reset the video mode. */
|
||||
void GraphicsWindow::DestroyGraphicsWindow()
|
||||
{
|
||||
if( g_HDC != NULL )
|
||||
if( g_HDC != nullptr )
|
||||
{
|
||||
ReleaseDC( g_hWndMain, g_HDC );
|
||||
g_HDC = NULL;
|
||||
g_HDC = nullptr;
|
||||
}
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
if( g_hWndMain != NULL )
|
||||
if( g_hWndMain != nullptr )
|
||||
{
|
||||
DestroyWindow( g_hWndMain );
|
||||
g_hWndMain = NULL;
|
||||
g_hWndMain = nullptr;
|
||||
CrashHandler::SetForegroundWindow( g_hWndMain );
|
||||
}
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
if( g_hIcon != NULL )
|
||||
if( g_hIcon != nullptr )
|
||||
{
|
||||
DestroyIcon( g_hIcon );
|
||||
g_hIcon = NULL;
|
||||
g_hIcon = nullptr;
|
||||
}
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
CHECKPOINT;
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
CHECKPOINT;
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
@@ -423,10 +423,10 @@ void GraphicsWindow::Initialize( bool bD3D )
|
||||
}
|
||||
|
||||
//if we have dwm, get function pointers to the dll functions
|
||||
if( hInstanceDwmapi != NULL )
|
||||
{
|
||||
PFN_DwmFlush = (HRESULT (WINAPI *)(VOID))GetProcAddress( hInstanceDwmapi, "DwmFlush" );
|
||||
PFN_DwmIsCompositionEnabled = (HRESULT (WINAPI *)(BOOL*))GetProcAddress( hInstanceDwmapi, "DwmIsCompositionEnabled" );
|
||||
if( hInstanceDwmapi != nullptr )
|
||||
{
|
||||
PFN_DwmFlush = (HRESULT (WINAPI *)(VOID))GetProcAddress( hInstanceDwmapi, "DwmFlush" );
|
||||
PFN_DwmIsCompositionEnabled = (HRESULT (WINAPI *)(BOOL*))GetProcAddress( hInstanceDwmapi, "DwmIsCompositionEnabled" );
|
||||
}
|
||||
|
||||
AppInstance inst;
|
||||
@@ -440,10 +440,10 @@ void GraphicsWindow::Initialize( bool bD3D )
|
||||
0, /* cbClsExtra */
|
||||
0, /* cbWndExtra */
|
||||
inst, /* hInstance */
|
||||
NULL, /* set icon later */
|
||||
LoadCursor( NULL, IDC_ARROW ), /* default cursor */
|
||||
NULL, /* hbrBackground */
|
||||
NULL, /* lpszMenuName */
|
||||
nullptr, /* set icon later */
|
||||
LoadCursor( nullptr, IDC_ARROW ), /* default cursor */
|
||||
nullptr, /* hbrBackground */
|
||||
nullptr, /* lpszMenuName */
|
||||
wsClassName.c_str() /* lpszClassName */
|
||||
};
|
||||
|
||||
@@ -458,10 +458,10 @@ void GraphicsWindow::Initialize( bool bD3D )
|
||||
0, /* cbClsExtra */
|
||||
0, /* cbWndExtra */
|
||||
inst, /* hInstance */
|
||||
NULL, /* set icon later */
|
||||
LoadCursor( NULL, IDC_ARROW ), /* default cursor */
|
||||
NULL, /* hbrBackground */
|
||||
NULL, /* lpszMenuName */
|
||||
nullptr, /* set icon later */
|
||||
LoadCursor( nullptr, IDC_ARROW ), /* default cursor */
|
||||
nullptr, /* hbrBackground */
|
||||
nullptr, /* lpszMenuName */
|
||||
g_sClassName /* lpszClassName */
|
||||
};
|
||||
|
||||
@@ -481,7 +481,7 @@ void GraphicsWindow::Shutdown()
|
||||
* It'd be nice to not do this: Windows will do it when we quit, and if
|
||||
* we're shutting down OpenGL to try D3D, this will cause extra mode
|
||||
* switches. However, we need to do this before displaying dialogs. */
|
||||
ChangeDisplaySettings( NULL, 0 );
|
||||
ChangeDisplaySettings( nullptr, 0 );
|
||||
|
||||
AppInstance inst;
|
||||
UnregisterClass( g_sClassName, inst );
|
||||
@@ -489,7 +489,7 @@ void GraphicsWindow::Shutdown()
|
||||
|
||||
HDC GraphicsWindow::GetHDC()
|
||||
{
|
||||
ASSERT( g_HDC != NULL );
|
||||
ASSERT( g_HDC != nullptr );
|
||||
return g_HDC;
|
||||
}
|
||||
|
||||
@@ -501,29 +501,29 @@ const VideoModeParams &GraphicsWindow::GetParams()
|
||||
void GraphicsWindow::Update()
|
||||
{
|
||||
MSG msg;
|
||||
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
GetMessage( &msg, NULL, 0, 0 );
|
||||
GetMessage( &msg, nullptr, 0, 0 );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
|
||||
HOOKS->SetHasFocus( g_bHasFocus );
|
||||
|
||||
if (g_CurrentParams.vsync)
|
||||
{
|
||||
//if we can use DWM
|
||||
if( hInstanceDwmapi != NULL )
|
||||
{
|
||||
BOOL compositeEnabled = true;
|
||||
PFN_DwmIsCompositionEnabled(&compositeEnabled);
|
||||
if (compositeEnabled)
|
||||
{
|
||||
{
|
||||
//if we can use DWM
|
||||
if( hInstanceDwmapi != nullptr )
|
||||
{
|
||||
BOOL compositeEnabled = true;
|
||||
PFN_DwmIsCompositionEnabled(&compositeEnabled);
|
||||
if (compositeEnabled)
|
||||
{
|
||||
PFN_DwmFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( g_bResolutionChanged && DISPLAY != NULL )
|
||||
if( g_bResolutionChanged && DISPLAY != nullptr )
|
||||
{
|
||||
//LOG->Warn( "Changing resolution" );
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace GraphicsWindow
|
||||
HWND GetHwnd();
|
||||
|
||||
//dwm functions for vista+
|
||||
static HINSTANCE hInstanceDwmapi = NULL;
|
||||
static HINSTANCE hInstanceDwmapi = nullptr;
|
||||
static HRESULT(WINAPI* PFN_DwmIsCompositionEnabled)(BOOL*);
|
||||
static HRESULT (WINAPI* PFN_DwmFlush)(VOID);
|
||||
};
|
||||
|
||||
@@ -14,10 +14,10 @@ MessageWindow::MessageWindow( const RString &sClassName )
|
||||
0, /* cbClsExtra */
|
||||
0, /* cbWndExtra */
|
||||
inst, /* hInstance */
|
||||
NULL, /* set icon later */
|
||||
LoadCursor( NULL, IDC_ARROW ), /* default cursor */
|
||||
NULL, /* hbrBackground */
|
||||
NULL, /* lpszMenuName */
|
||||
nullptr, /* set icon later */
|
||||
LoadCursor( nullptr, IDC_ARROW ), /* default cursor */
|
||||
nullptr, /* hbrBackground */
|
||||
nullptr, /* lpszMenuName */
|
||||
sClassName /* lpszClassName */
|
||||
};
|
||||
|
||||
@@ -25,8 +25,8 @@ MessageWindow::MessageWindow( const RString &sClassName )
|
||||
RageException::Throw( "%s", werr_ssprintf( GetLastError(), "RegisterClass" ).c_str() );
|
||||
|
||||
// XXX: on 2k/XP, use HWND_MESSAGE as parent
|
||||
m_hWnd = CreateWindow( sClassName, sClassName, WS_DISABLED, 0, 0, 0, 0, NULL, NULL, inst, NULL );
|
||||
ASSERT( m_hWnd != NULL );
|
||||
m_hWnd = CreateWindow( sClassName, sClassName, WS_DISABLED, 0, 0, 0, 0, nullptr, nullptr, inst, nullptr );
|
||||
ASSERT( m_hWnd != nullptr );
|
||||
|
||||
SetProp( m_hWnd, "MessageWindow", this );
|
||||
}
|
||||
@@ -60,7 +60,7 @@ void MessageWindow::StopRunning()
|
||||
LRESULT CALLBACK MessageWindow::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
MessageWindow *pThis = (MessageWindow *) GetProp( hWnd, "MessageWindow" );
|
||||
if( pThis != NULL && pThis->HandleMessage(msg, wParam, lParam) )
|
||||
if( pThis != nullptr && pThis->HandleMessage(msg, wParam, lParam) )
|
||||
return 0;
|
||||
|
||||
return DefWindowProc( hWnd, msg, wParam, lParam );
|
||||
|
||||
@@ -36,14 +36,14 @@ static bool GetRegKeyType( const RString &sIn, RString &sOut, HKEY &key )
|
||||
}
|
||||
|
||||
/* Given a full key, eg. "HKEY_LOCAL_MACHINE\hardware\foo", open it and return it.
|
||||
* On error, return NULL. */
|
||||
* On error, return nullptr. */
|
||||
enum RegKeyMode { READ, WRITE };
|
||||
static HKEY OpenRegKey( const RString &sKey, RegKeyMode mode, bool bWarnOnError = true )
|
||||
{
|
||||
RString sSubkey;
|
||||
HKEY hType;
|
||||
if( !GetRegKeyType(sKey, sSubkey, hType) )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
HKEY hRetKey;
|
||||
LONG retval = RegOpenKeyEx( hType, sSubkey, 0, (mode==READ) ? KEY_READ:KEY_WRITE, &hRetKey );
|
||||
@@ -51,7 +51,7 @@ static HKEY OpenRegKey( const RString &sKey, RegKeyMode mode, bool bWarnOnError
|
||||
{
|
||||
if( bWarnOnError )
|
||||
LOG->Warn( werr_ssprintf(retval, "RegOpenKeyEx(%x,%s) error", hType, sSubkey.c_str()) );
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return hRetKey;
|
||||
@@ -60,13 +60,13 @@ static HKEY OpenRegKey( const RString &sKey, RegKeyMode mode, bool bWarnOnError
|
||||
bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, RString &sVal )
|
||||
{
|
||||
HKEY hKey = OpenRegKey( sKey, READ );
|
||||
if( hKey == NULL )
|
||||
if( hKey == nullptr )
|
||||
return false;
|
||||
|
||||
char sBuffer[MAX_PATH];
|
||||
DWORD iSize = sizeof(sBuffer);
|
||||
DWORD iType;
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, NULL, &iType, (LPBYTE)sBuffer, &iSize );
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, nullptr, &iType, (LPBYTE)sBuffer, &iSize );
|
||||
RegCloseKey( hKey );
|
||||
if( iRet != ERROR_SUCCESS )
|
||||
return false;
|
||||
@@ -86,13 +86,13 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, RSt
|
||||
bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, int &iVal, bool bWarnOnError )
|
||||
{
|
||||
HKEY hKey = OpenRegKey( sKey, READ, bWarnOnError );
|
||||
if( hKey == NULL )
|
||||
if( hKey == nullptr )
|
||||
return false;
|
||||
|
||||
DWORD iValue;
|
||||
DWORD iSize = sizeof(iValue);
|
||||
DWORD iType;
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, NULL, &iType, (LPBYTE) &iValue, &iSize );
|
||||
LONG iRet = RegQueryValueEx( hKey, sName, nullptr, &iType, (LPBYTE) &iValue, &iSize );
|
||||
RegCloseKey( hKey );
|
||||
if( iRet != ERROR_SUCCESS )
|
||||
return false;
|
||||
@@ -115,7 +115,7 @@ bool RegistryAccess::GetRegValue( const RString &sKey, const RString &sName, boo
|
||||
bool RegistryAccess::GetRegSubKeys( const RString &sKey, vector<RString> &lst, const RString ®ex, bool bReturnPathToo )
|
||||
{
|
||||
HKEY hKey = OpenRegKey( sKey, READ );
|
||||
if( hKey == NULL )
|
||||
if( hKey == nullptr )
|
||||
return false;
|
||||
|
||||
Regex re(regex);
|
||||
@@ -126,7 +126,7 @@ bool RegistryAccess::GetRegSubKeys( const RString &sKey, vector<RString> &lst, c
|
||||
FILETIME ft;
|
||||
char szBuffer[MAX_PATH];
|
||||
DWORD iSize = sizeof(szBuffer);
|
||||
LONG iRet = RegEnumKeyEx( hKey, index, szBuffer, &iSize, NULL, NULL, NULL, &ft);
|
||||
LONG iRet = RegEnumKeyEx( hKey, index, szBuffer, &iSize, nullptr, nullptr, nullptr, &ft);
|
||||
if( iRet == ERROR_NO_MORE_ITEMS )
|
||||
break;
|
||||
|
||||
@@ -155,7 +155,7 @@ bool RegistryAccess::GetRegSubKeys( const RString &sKey, vector<RString> &lst, c
|
||||
bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, const RString &sVal )
|
||||
{
|
||||
HKEY hKey = OpenRegKey( sKey, WRITE );
|
||||
if( hKey == NULL )
|
||||
if( hKey == nullptr )
|
||||
return false;
|
||||
|
||||
bool bSuccess = true;
|
||||
@@ -177,7 +177,7 @@ bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, con
|
||||
bool RegistryAccess::SetRegValue( const RString &sKey, const RString &sName, bool bVal )
|
||||
{
|
||||
HKEY hKey = OpenRegKey( sKey, WRITE );
|
||||
if( hKey == NULL )
|
||||
if( hKey == nullptr )
|
||||
return false;
|
||||
|
||||
bool bSuccess = true;
|
||||
@@ -196,7 +196,7 @@ bool RegistryAccess::CreateKey( const RString &sKey )
|
||||
RString sSubkey;
|
||||
HKEY hType;
|
||||
if( !GetRegKeyType(sKey, sSubkey, hType) )
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
HKEY hKey;
|
||||
DWORD dwDisposition = 0;
|
||||
@@ -204,10 +204,10 @@ bool RegistryAccess::CreateKey( const RString &sKey )
|
||||
hType,
|
||||
sSubkey,
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
nullptr,
|
||||
&hKey,
|
||||
&dwDisposition ) != ERROR_SUCCESS )
|
||||
{
|
||||
|
||||
@@ -5,21 +5,21 @@
|
||||
void Win32RestartProgram()
|
||||
{
|
||||
TCHAR szFullAppPath[MAX_PATH];
|
||||
GetModuleFileName(NULL, szFullAppPath, MAX_PATH);
|
||||
GetModuleFileName(nullptr, szFullAppPath, MAX_PATH);
|
||||
|
||||
// Relaunch
|
||||
PROCESS_INFORMATION pi;
|
||||
STARTUPINFO si;
|
||||
ZeroMemory( &si, sizeof(si) );
|
||||
CreateProcess(
|
||||
NULL, // pointer to name of executable module
|
||||
nullptr, // pointer to name of executable module
|
||||
szFullAppPath, // pointer to command line string
|
||||
NULL, // process security attributes
|
||||
NULL, // thread security attributes
|
||||
nullptr, // process security attributes
|
||||
nullptr, // thread security attributes
|
||||
false, // handle inheritance flag
|
||||
0, // creation flags
|
||||
NULL, // pointer to new environment block
|
||||
NULL, // pointer to current directory name
|
||||
nullptr, // pointer to new environment block
|
||||
nullptr, // pointer to current directory name
|
||||
&si, // pointer to STARTUPINFO
|
||||
&pi // pointer to PROCESS_INFORMATION
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ static RString GetSpecialFolderPath( int csidl )
|
||||
{
|
||||
RString sDir;
|
||||
TCHAR szDir[MAX_PATH] = "";
|
||||
HRESULT hResult = SHGetFolderPath( NULL, csidl, NULL, SHGFP_TYPE_CURRENT, szDir );
|
||||
HRESULT hResult = SHGetFolderPath( nullptr, csidl, nullptr, SHGFP_TYPE_CURRENT, szDir );
|
||||
ASSERT( hResult == S_OK );
|
||||
sDir = szDir;
|
||||
sDir += "/";
|
||||
|
||||
@@ -20,27 +20,27 @@ static RString GetUSBDevicePath( int iNum )
|
||||
GUID guid;
|
||||
HidD_GetHidGuid( &guid );
|
||||
|
||||
HDEVINFO DeviceInfo = SetupDiGetClassDevs( &guid, NULL, NULL, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE) );
|
||||
HDEVINFO DeviceInfo = SetupDiGetClassDevs( &guid, nullptr, nullptr, (DIGCF_PRESENT | DIGCF_DEVICEINTERFACE) );
|
||||
|
||||
SP_DEVICE_INTERFACE_DATA DeviceInterface;
|
||||
DeviceInterface.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
|
||||
if( !SetupDiEnumDeviceInterfaces (DeviceInfo,
|
||||
NULL, &guid, iNum, &DeviceInterface) )
|
||||
nullptr, &guid, iNum, &DeviceInterface) )
|
||||
{
|
||||
SetupDiDestroyDeviceInfoList( DeviceInfo );
|
||||
return RString();
|
||||
}
|
||||
|
||||
unsigned long iSize;
|
||||
SetupDiGetDeviceInterfaceDetail( DeviceInfo, &DeviceInterface, NULL, 0, &iSize, 0 );
|
||||
SetupDiGetDeviceInterfaceDetail( DeviceInfo, &DeviceInterface, nullptr, 0, &iSize, 0 );
|
||||
|
||||
PSP_INTERFACE_DEVICE_DETAIL_DATA DeviceDetail = (PSP_INTERFACE_DEVICE_DETAIL_DATA) malloc( iSize );
|
||||
DeviceDetail->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
|
||||
|
||||
RString sRet;
|
||||
if( SetupDiGetDeviceInterfaceDetail(DeviceInfo, &DeviceInterface,
|
||||
DeviceDetail, iSize, &iSize, NULL) )
|
||||
DeviceDetail, iSize, &iSize, nullptr) )
|
||||
sRet = DeviceDetail->DevicePath;
|
||||
free( DeviceDetail );
|
||||
|
||||
@@ -56,7 +56,7 @@ bool USBDevice::Open( int iVID, int iPID, int iBlockSize, int iNum, void (*pfnIn
|
||||
while( (path = GetUSBDevicePath(iIndex++)) != "" )
|
||||
{
|
||||
HANDLE h = CreateFile( path, GENERIC_READ,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL );
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr );
|
||||
|
||||
if( h == INVALID_HANDLE_VALUE )
|
||||
continue;
|
||||
@@ -115,7 +115,7 @@ WindowsFileIO::WindowsFileIO()
|
||||
{
|
||||
ZeroMemory( &m_Overlapped, sizeof(m_Overlapped) );
|
||||
m_Handle = INVALID_HANDLE_VALUE;
|
||||
m_pBuffer = NULL;
|
||||
m_pBuffer = nullptr;
|
||||
}
|
||||
|
||||
WindowsFileIO::~WindowsFileIO()
|
||||
@@ -138,7 +138,7 @@ bool WindowsFileIO::Open( RString path, int iBlockSize )
|
||||
CloseHandle( m_Handle );
|
||||
|
||||
m_Handle = CreateFile( path, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL );
|
||||
nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr );
|
||||
|
||||
if( m_Handle == INVALID_HANDLE_VALUE )
|
||||
return false;
|
||||
|
||||
@@ -18,7 +18,7 @@ RString GetPrimaryVideoName()
|
||||
|
||||
// VC6 don't have a stub to static link with, so link dynamically.
|
||||
EnumDisplayDevices = (pfnEnumDisplayDevices)GetProcAddress(hInstUser32,"EnumDisplayDevicesA");
|
||||
if( EnumDisplayDevices == NULL )
|
||||
if( EnumDisplayDevices == nullptr )
|
||||
{
|
||||
FreeLibrary(hInstUser32);
|
||||
return RString();
|
||||
@@ -30,7 +30,7 @@ RString GetPrimaryVideoName()
|
||||
DISPLAY_DEVICE dd;
|
||||
ZERO( dd );
|
||||
dd.cb = sizeof(dd);
|
||||
if( !EnumDisplayDevices(NULL, i, &dd, 0) )
|
||||
if( !EnumDisplayDevices(nullptr, i, &dd, 0) )
|
||||
break;
|
||||
if( dd.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE )
|
||||
{
|
||||
|
||||
@@ -77,13 +77,13 @@ HICON IconFromSurface( const RageSurface *pSrcImg )
|
||||
HICON icon = CreateIconFromResourceEx( (BYTE *) pBitmap, iSize + iSizeImage, TRUE, 0x00030000, pImg->w, pImg->h, LR_DEFAULTCOLOR );
|
||||
|
||||
delete pImg;
|
||||
pImg = NULL;
|
||||
pImg = nullptr;
|
||||
free( pBitmap );
|
||||
|
||||
if( icon == NULL )
|
||||
if( icon == nullptr )
|
||||
{
|
||||
LOG->Trace( "%s", werr_ssprintf( GetLastError(), "CreateIconFromResourceEx" ).c_str() );
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return icon;
|
||||
@@ -93,10 +93,10 @@ HICON IconFromFile( const RString &sIconFile )
|
||||
{
|
||||
RString sError;
|
||||
RageSurface *pImg = RageSurfaceUtils::LoadFile( sIconFile, sError );
|
||||
if( pImg == NULL )
|
||||
if( pImg == nullptr )
|
||||
{
|
||||
LOG->Warn( "Couldn't open icon \"%s\": %s", sIconFile.c_str(), sError.c_str() );
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HICON icon = IconFromSurface( pImg );
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
|
||||
WindowsDialogBox::WindowsDialogBox()
|
||||
{
|
||||
m_hWnd = NULL;
|
||||
m_hWnd = nullptr;
|
||||
}
|
||||
|
||||
void WindowsDialogBox::Run( int iDialog )
|
||||
{
|
||||
char szFullAppPath[MAX_PATH];
|
||||
GetModuleFileName( NULL, szFullAppPath, MAX_PATH );
|
||||
GetModuleFileName( nullptr, szFullAppPath, MAX_PATH );
|
||||
HINSTANCE hHandle = LoadLibrary( szFullAppPath );
|
||||
|
||||
DialogBoxParam( hHandle, MAKEINTRESOURCE(iDialog), NULL, DlgProc, (LPARAM) this );
|
||||
DialogBoxParam( hHandle, MAKEINTRESOURCE(iDialog), nullptr, DlgProc, (LPARAM) this );
|
||||
}
|
||||
|
||||
BOOL APIENTRY WindowsDialogBox::DlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
@@ -21,10 +21,10 @@ BOOL APIENTRY WindowsDialogBox::DlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPA
|
||||
SetProp( hDlg, "WindowsDialogBox", (HANDLE) lParam );
|
||||
|
||||
WindowsDialogBox *pThis = (WindowsDialogBox *) GetProp( hDlg, "WindowsDialogBox" );
|
||||
if( pThis == NULL )
|
||||
if( pThis == nullptr )
|
||||
return FALSE;
|
||||
|
||||
if( pThis->m_hWnd == NULL )
|
||||
if( pThis->m_hWnd == nullptr )
|
||||
pThis->m_hWnd = hDlg;
|
||||
|
||||
return pThis->HandleMessage( msg, wParam, lParam );
|
||||
|
||||
@@ -36,7 +36,7 @@ char *strtack(char *s, const char *t, const char *s_max) {
|
||||
++s, ++t;
|
||||
|
||||
if (s == s_max)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
return s+1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user