From 552175e2de2e03d1ea9dc5a7667559c7a50e5a65 Mon Sep 17 00:00:00 2001 From: Li Linfeng Date: Sat, 21 Sep 2019 14:11:41 +0800 Subject: [PATCH] fix warnings --- macosx/CelestiaController.h | 2 +- macosx/CelestiaController.m | 2 +- macosx/CelestiaFavorite.mm | 1 - macosx/CelestiaFavorites.h | 2 +- macosx/CelestiaOpenGLView.mm | 2 +- macosx/CelestiaSettings.h | 2 +- macosx/CelestiaSettings.mm | 48 ++++++------------------------ macosx/FavoritesDrawerController.h | 4 +-- macosx/ImageAndTextCell.m | 4 +-- src/celengine/glext.cpp | 28 +++-------------- src/celengine/marker.cpp | 2 +- src/celestia/url.cpp | 2 +- 12 files changed, 24 insertions(+), 75 deletions(-) diff --git a/macosx/CelestiaController.h b/macosx/CelestiaController.h index 8e4895da7..8dfc29f25 100644 --- a/macosx/CelestiaController.h +++ b/macosx/CelestiaController.h @@ -21,7 +21,7 @@ @class ScriptsController; @class ConfigSelectionWindowController; -@interface CelestiaController : NSWindowController +@interface CelestiaController : NSWindowController { CelestiaSettings* settings; CelestiaAppCore* appCore; diff --git a/macosx/CelestiaController.m b/macosx/CelestiaController.m index 16f2b1893..7c3ed5ef1 100644 --- a/macosx/CelestiaController.m +++ b/macosx/CelestiaController.m @@ -640,7 +640,7 @@ NSString* fatalErrorMessage; // Close the original window (does not release it) [origWindow close]; glView = fullScreenView; - [glView takeValue: self forKey: @"controller"]; + [glView setValue: self forKey: @"controller"]; [fullScreenWindow makeFirstResponder: glView]; // Make sure the view looks ready before unfading from black [glView update]; diff --git a/macosx/CelestiaFavorite.mm b/macosx/CelestiaFavorite.mm index e2f32e5af..f50f7d5a1 100644 --- a/macosx/CelestiaFavorite.mm +++ b/macosx/CelestiaFavorite.mm @@ -12,7 +12,6 @@ #import "CelestiaUniversalCoord_PrivateAPI.h" #import "NSString_ObjCPlusPlus.h" #import "Astro.h" -#import "Observer.h" #import "CelestiaAppCore.h" #import "CelestiaSimulation.h" #import "CelestiaSimulation_PrivateAPI.h" diff --git a/macosx/CelestiaFavorites.h b/macosx/CelestiaFavorites.h index 5293bf4c0..d6857f69c 100644 --- a/macosx/CelestiaFavorites.h +++ b/macosx/CelestiaFavorites.h @@ -7,7 +7,7 @@ // #import "CelestiaFavorite.h" -#import "myTree.h" +#import "MyTree.h" @interface CelestiaFavorites : MyTree diff --git a/macosx/CelestiaOpenGLView.mm b/macosx/CelestiaOpenGLView.mm index 73b2f408c..22fb957e8 100644 --- a/macosx/CelestiaOpenGLView.mm +++ b/macosx/CelestiaOpenGLView.mm @@ -479,7 +479,7 @@ } return NO; } -- (unsigned int) draggingEntered: (id ) sender +- (NSDragOperation) draggingEntered: (id ) sender { NSPasteboard *pb = [sender draggingPasteboard]; NSString *type = [pb availableTypeFromArray: diff --git a/macosx/CelestiaSettings.h b/macosx/CelestiaSettings.h index 4df24e9a0..a83936667 100644 --- a/macosx/CelestiaSettings.h +++ b/macosx/CelestiaSettings.h @@ -19,7 +19,7 @@ -(void) setControl: (id) _control; -(id) valueForTag: (int) tag; --(void) takeValue: (id) value forTag: (int) tag; +-(void) setValue: (id) value forTag: (int) tag; // User Defaults diff --git a/macosx/CelestiaSettings.mm b/macosx/CelestiaSettings.mm index 7039fb8bb..e36a093dc 100644 --- a/macosx/CelestiaSettings.mm +++ b/macosx/CelestiaSettings.mm @@ -29,14 +29,14 @@ class MacOSXWatcher : public CelestiaWatcher void notifyChange(CelestiaCore* core, int i) { - if ( 0 == i & ( + if ( 0 == (i & ( CelestiaCore::LabelFlagsChanged | CelestiaCore::RenderFlagsChanged | CelestiaCore::VerbosityLevelChanged | CelestiaCore::TimeZoneChanged | CelestiaCore::AmbientLightChanged | CelestiaCore::FaintestChanged - )) { return; } + ))) { return; } [control validateItems]; }; }; @@ -274,7 +274,7 @@ static NSMutableDictionary* tagMap; #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 [self setValue: [defaultsDictionary objectForKey: key] forKey: key]; #else - [self takeValue: [defaultsDictionary objectForKey: key] forKey: key]; + [self setValue: [defaultsDictionary objectForKey: key] forKey: key]; #endif } } @@ -316,20 +316,15 @@ static NSMutableDictionary* tagMap; return [self valueForKey: [tagDict objectForKey: [NSNumber numberWithInt: tag] ] ]; } --(void) takeValue: (id) value forTag: (int) tag +-(void) setValue: (id) value forTag: (int) tag { id key = [tagDict objectForKey: [NSNumber numberWithInt: tag] ]; if (key!= nil) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 [self setValue: value forKey: key ]; -#else - [self takeValue: value forKey: key ]; -#endif } } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 - (id)valueForUndefinedKey: (NSString *) key { #ifdef DEBUG @@ -352,31 +347,6 @@ static NSMutableDictionary* tagMap; #endif } -#else - --(id)handleQueryWithUnboundKey: (NSString*) key -{ -#ifdef DEBUG - if ( key ) NSLog(@"unbound key query for %@", key); -#endif - return nil; -} - --(void)handleTakeValue: (id) value forUnboundKey: (NSString*) key -{ -#ifdef DEBUG - NSLog(@"unbound key set for %@", key); -#endif -} - --(void)unableToSetNilForKey: (NSString*) key -{ -#ifdef DEBUG - NSLog(@"nil key for %@", key); -#endif -} -#endif - // Time Settings -(double) time { return appCore->getSimulation()->getTime(); } @@ -658,7 +628,7 @@ FEATUREMETHODS(Other) #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 [control setValue: [NSNumber numberWithBool: (value != 0)] forKey: @"isFullScreen"]; #else - [control takeValue: [NSNumber numberWithBool: (value != 0)] forKey: @"isFullScreen"]; + [control setValue: [NSNumber numberWithBool: (value != 0)] forKey: @"isFullScreen"]; #endif } @@ -675,7 +645,7 @@ FEATUREMETHODS(Other) if ( surfaces && [surfaces count] > 0 ) { NSString *displayedSurfStr = [NSString stringWithStdString: displayedSurfName]; - unsigned index = [surfaces indexOfObject: displayedSurfStr]; + NSUInteger index = [surfaces indexOfObject: displayedSurfStr]; if (index != NSNotFound) return index+1; } @@ -731,11 +701,11 @@ FEATUREMETHODS(Other) switch ( tag/100) { case 4: case 5: case 7: case 8: case 10: // 400, 500, 700, 800, 1000 - [self takeValue: [NSNumber numberWithInt: (1-[[self valueForTag: tag] intValue])] forTag: tag ]; + [self setValue: [NSNumber numberWithInt: (1-[[self valueForTag: tag] intValue])] forTag: tag ]; break; case 6: // 600 value = [NSNumber numberWithInt: tag%10 ]; - [self takeValue: value forTag: (tag/10)*10 ]; + [self setValue: value forTag: (tag/10)*10 ]; [self selectPopUpButtonItem: item withIndex: tag%10]; //[self setPopUpButtonWithTag: ((tag/10)*10) toIndex: [value intValue]]; if ([[tagDict objectForKey:[NSNumber numberWithInt:((tag/10)*10)]] isEqualToString: @"renderPath"]) @@ -748,7 +718,7 @@ FEATUREMETHODS(Other) } break; case 9: // 900 - [self takeValue: [NSNumber numberWithFloat: [item floatValue]] forTag: tag]; + [self setValue: [NSNumber numberWithFloat: [item floatValue]] forTag: tag]; break; } } diff --git a/macosx/FavoritesDrawerController.h b/macosx/FavoritesDrawerController.h index bb2db64c0..9838e098a 100644 --- a/macosx/FavoritesDrawerController.h +++ b/macosx/FavoritesDrawerController.h @@ -1,7 +1,7 @@ /* FavoritesDrawerController */ -#import "CelestiaFavorite.h"; -#import "ContextOutlineView.h"; +#import "CelestiaFavorite.h" +#import "ContextOutlineView.h" #import "FavoriteInfoWindowController.h" #import "NSWindowController_Extensions.h" diff --git a/macosx/ImageAndTextCell.m b/macosx/ImageAndTextCell.m index 6a6121a6f..d8ceeeea1 100644 --- a/macosx/ImageAndTextCell.m +++ b/macosx/ImageAndTextCell.m @@ -88,7 +88,7 @@ [super editWithFrame: textFrame inView: controlView editor:textObj delegate:anObject event: theEvent]; } -- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart length:(int)selLength { +- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength { NSRect textFrame, imageFrame; NSDivideRect (aRect, &imageFrame, &textFrame, 3 + [image size].width, NSMinXEdge); [super selectWithFrame: textFrame inView: controlView editor:textObj delegate:anObject start:selStart length:selLength]; @@ -124,4 +124,4 @@ return cellSize; } -@end \ No newline at end of file +@end diff --git a/src/celengine/glext.cpp b/src/celengine/glext.cpp index 0f04423dd..4bde79252 100644 --- a/src/celengine/glext.cpp +++ b/src/celengine/glext.cpp @@ -346,16 +346,14 @@ FUNCS GetGLProcAddress(const GLubyte* procName) #ifdef TARGET_OS_MAC +#include #include #include typedef void (*FUNCS) (void); -const struct mach_header *openGLImagePtr = NULL; +static void *openGLImagePtr = NULL; FUNCS osxGetProcAddress(const GLubyte *procName) { - char myProcName[128]; - NSSymbol mySymbol = NULL; - FUNCS myPtr = NULL; if (openGLImagePtr == NULL) { - openGLImagePtr = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL",NSADDIMAGE_OPTION_RETURN_ON_ERROR); + openGLImagePtr = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL", RTLD_LAZY); #if 0 unsigned long i; unsigned long imageCount = _dyld_image_count(); @@ -373,29 +371,11 @@ FUNCS osxGetProcAddress(const GLubyte *procName) { printf("Can't find OpenGL??\n"); return NULL; } - strcpy(myProcName,"_"); - - /* sanity check */ - if (strlen((char *)procName)>125) return NULL; - strcat(myProcName,(char *)procName); - //printf("%s\n",myProcName); - //if (NSIsSymbolNameDefinedInImage(openGLImagePtr,myProcName) != FALSE) { - mySymbol = NSLookupSymbolInImage(openGLImagePtr, myProcName, NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); - if (mySymbol != NULL) - myPtr = (FUNCS)NSAddressOfSymbol(mySymbol); - //printf(" (symbol, address) -> (%08x -> %08x)\n",(unsigned int)mySymbol,(unsigned int)myPtr); - return myPtr; - //} + return (FUNCS)dlsym(openGLImagePtr, (char *)procName); } #define GET_GL_PROC_ADDRESS(name) osxGetProcAddress((GLubyte *)name) #endif /* TARGET_OS_MAC */ - -void Alert(const char /* *szFormat*/, ...) -{ -} - - // ARB_multitexture static void InitExt_ARB_multitexture() { diff --git a/src/celengine/marker.cpp b/src/celengine/marker.cpp index fe1ba901a..ae9134cb2 100644 --- a/src/celengine/marker.cpp +++ b/src/celengine/marker.cpp @@ -153,7 +153,7 @@ void MarkerRepresentation::render(float size) const #ifndef _MSC_VER #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif switch (m_symbol) { diff --git a/src/celestia/url.cpp b/src/celestia/url.cpp index a3f08ecee..2507174ab 100644 --- a/src/celestia/url.cpp +++ b/src/celestia/url.cpp @@ -355,7 +355,7 @@ Url::Url(CelestiaCore* core, UrlType type) #ifndef _MSC_VER #pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" +#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" #endif switch (type) { case Absolute: // Intentional Fall-Through