summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2023-02-03 16:53:33 +0200
committerMaxim Nikolenko <maximnproductengine@lindenlab.com>2023-02-03 16:53:33 +0200
commit51142d1341bfd5f4f9749fe1aaf23d4f4270fe0e (patch)
tree1ced5dc14755b357886eb9fdf3606f5073ed9aaa /indra/llwindow
parentdb80fdb55b646164a71c58e9f4751b368afa3b9f (diff)
parent8d21d29bd7fa038db632ff90fb0e1207d0713ca2 (diff)
Merge branch 'main' into DRTVWR-567
# Conflicts: # indra/newview/llappearancemgr.cpp # indra/newview/llpanelmaininventory.cpp
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/lldxhardware.cpp2
-rw-r--r--indra/llwindow/llopenglview-objc.mm7
-rw-r--r--indra/llwindow/llwindowmacosx-objc.h2
-rw-r--r--indra/llwindow/llwindowmacosx-objc.mm136
-rw-r--r--indra/llwindow/llwindowmacosx.cpp14
-rw-r--r--indra/llwindow/llwindowmacosx.h1
6 files changed, 86 insertions, 76 deletions
diff --git a/indra/llwindow/lldxhardware.cpp b/indra/llwindow/lldxhardware.cpp
index 81e938edbe..391a377280 100644
--- a/indra/llwindow/lldxhardware.cpp
+++ b/indra/llwindow/lldxhardware.cpp
@@ -1098,7 +1098,7 @@ LLSD LLDXHardware::getDisplayInfo()
}
LCleanup:
- if (ret.emptyMap())
+ if (!ret.isMap() || (ret.size() == 0))
{
LL_INFOS() << "Failed to get data, cleaning up" << LL_ENDL;
}
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 049226db65..7936245744 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -495,7 +495,12 @@ attributedStringInfo getSegments(NSAttributedString *str)
// e.g. OS Window for upload something or Input Window...
// mModifiers instance variable is for insertText: or insertText:replacementRange: (by Pell Smit)
mModifiers = [theEvent modifierFlags];
- unichar ch = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
+ NSString *str_no_modifiers = [theEvent charactersIgnoringModifiers];
+ unichar ch = 0;
+ if (str_no_modifiers.length)
+ {
+ ch = [str_no_modifiers characterAtIndex:0];
+ }
bool acceptsText = mHasMarkedText ? false : callKeyDown(&eventData, keycode, mModifiers, ch);
if (acceptsText &&
diff --git a/indra/llwindow/llwindowmacosx-objc.h b/indra/llwindow/llwindowmacosx-objc.h
index 43edc0110d..77024d3a9c 100644
--- a/indra/llwindow/llwindowmacosx-objc.h
+++ b/indra/llwindow/llwindowmacosx-objc.h
@@ -83,7 +83,7 @@ int createNSApp(int argc, const char **argv);
void setupCocoa();
bool pasteBoardAvailable();
bool copyToPBoard(const unsigned short *str, unsigned int len);
-const unsigned short *copyFromPBoard();
+unsigned short *copyFromPBoard();
CursorRef createImageCursor(const char *fullpath, int hotspotX, int hotspotY);
short releaseImageCursor(CursorRef ref);
short setImageCursor(CursorRef ref);
diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm
index 5ec9b017cf..57c3d86295 100644
--- a/indra/llwindow/llwindowmacosx-objc.mm
+++ b/indra/llwindow/llwindowmacosx-objc.mm
@@ -49,14 +49,12 @@ void setupCocoa()
if(!inited)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- // The following prevents the Cocoa command line parser from trying to open 'unknown' arguements as documents.
- // ie. running './secondlife -set Language fr' would cause a pop-up saying can't open document 'fr'
- // when init'ing the Cocoa App window.
- [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];
-
- [pool release];
+ @autoreleasepool {
+ // The following prevents the Cocoa command line parser from trying to open 'unknown' arguements as documents.
+ // ie. running './secondlife -set Language fr' would cause a pop-up saying can't open document 'fr'
+ // when init'ing the Cocoa App window.
+ [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];
+ }
inited = true;
}
@@ -64,13 +62,13 @@ void setupCocoa()
bool copyToPBoard(const unsigned short *str, unsigned int len)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
- NSPasteboard *pboard = [NSPasteboard generalPasteboard];
- [pboard clearContents];
-
- NSArray *contentsToPaste = [[NSArray alloc] initWithObjects:[NSString stringWithCharacters:str length:len], nil];
- [pool release];
- return [pboard writeObjects:contentsToPaste];
+ @autoreleasepool {
+ NSPasteboard *pboard = [NSPasteboard generalPasteboard];
+ [pboard clearContents];
+
+ NSArray *contentsToPaste = [[[NSArray alloc] initWithObjects:[NSString stringWithCharacters:str length:len], nil] autorelease];
+ return [pboard writeObjects:contentsToPaste];
+ }
}
bool pasteBoardAvailable()
@@ -79,39 +77,39 @@ bool pasteBoardAvailable()
return [[NSPasteboard generalPasteboard] canReadObjectForClasses:classArray options:[NSDictionary dictionary]];
}
-const unsigned short *copyFromPBoard()
+unsigned short *copyFromPBoard()
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
- NSPasteboard *pboard = [NSPasteboard generalPasteboard];
- NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
- NSString *str = NULL;
- BOOL ok = [pboard canReadObjectForClasses:classArray options:[NSDictionary dictionary]];
- if (ok)
- {
- NSArray *objToPaste = [pboard readObjectsForClasses:classArray options:[NSDictionary dictionary]];
- str = [objToPaste objectAtIndex:0];
- }
- unichar* temp = (unichar*)calloc([str length]+1, sizeof(unichar));
- [str getCharacters:temp];
- [pool release];
- return temp;
+ @autoreleasepool {
+ NSPasteboard *pboard = [NSPasteboard generalPasteboard];
+ NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
+ NSString *str = NULL;
+ BOOL ok = [pboard canReadObjectForClasses:classArray options:[NSDictionary dictionary]];
+ if (ok)
+ {
+ NSArray *objToPaste = [pboard readObjectsForClasses:classArray options:[NSDictionary dictionary]];
+ str = [objToPaste objectAtIndex:0];
+ }
+ NSUInteger str_len = [str length];
+ unichar* temp = (unichar*)calloc(str_len+1, sizeof(unichar));
+ [str getCharacters:temp range:NSMakeRange(0, str_len)];
+ return temp;
+ }
}
CursorRef createImageCursor(const char *fullpath, int hotspotX, int hotspotY)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- // extra retain on the NSCursor since we want it to live for the lifetime of the app.
- NSCursor *cursor =
- [[[NSCursor alloc]
- initWithImage:
- [[[NSImage alloc] initWithContentsOfFile:
- [NSString stringWithUTF8String:fullpath]
- ]autorelease]
- hotSpot:NSMakePoint(hotspotX, hotspotY)
- ]retain];
-
- [pool release];
+ NSCursor *cursor = nil;
+ @autoreleasepool {
+ // extra retain on the NSCursor since we want it to live for the lifetime of the app.
+ cursor =
+ [[[NSCursor alloc]
+ initWithImage:
+ [[[NSImage alloc] initWithContentsOfFile:
+ [NSString stringWithUTF8String:fullpath]
+ ] autorelease]
+ hotSpot:NSMakePoint(hotspotX, hotspotY)
+ ] retain];
+ }
return (CursorRef)cursor;
}
@@ -178,10 +176,10 @@ OSErr releaseImageCursor(CursorRef ref)
{
if( ref != NULL )
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSCursor *cursor = (NSCursor*)ref;
- [cursor release];
- [pool release];
+ @autoreleasepool {
+ NSCursor *cursor = (NSCursor*)ref;
+ [cursor autorelease];
+ }
}
else
{
@@ -195,10 +193,10 @@ OSErr setImageCursor(CursorRef ref)
{
if( ref != NULL )
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- NSCursor *cursor = (NSCursor*)ref;
- [cursor set];
- [pool release];
+ @autoreleasepool {
+ NSCursor *cursor = (NSCursor*)ref;
+ [cursor set];
+ }
}
else
{
@@ -419,24 +417,26 @@ void requestUserAttention()
long showAlert(std::string text, std::string title, int type)
{
- NSAlert *alert = [[NSAlert alloc] init];
-
- [alert setMessageText:[NSString stringWithCString:title.c_str() encoding:[NSString defaultCStringEncoding]]];
- [alert setInformativeText:[NSString stringWithCString:text.c_str() encoding:[NSString defaultCStringEncoding]]];
- if (type == 0)
- {
- [alert addButtonWithTitle:@"Okay"];
- } else if (type == 1)
- {
- [alert addButtonWithTitle:@"Okay"];
- [alert addButtonWithTitle:@"Cancel"];
- } else if (type == 2)
- {
- [alert addButtonWithTitle:@"Yes"];
- [alert addButtonWithTitle:@"No"];
+ long ret = 0;
+ @autoreleasepool {
+ NSAlert *alert = [[[NSAlert alloc] init] autorelease];
+
+ [alert setMessageText:[NSString stringWithCString:title.c_str() encoding:[NSString defaultCStringEncoding]]];
+ [alert setInformativeText:[NSString stringWithCString:text.c_str() encoding:[NSString defaultCStringEncoding]]];
+ if (type == 0)
+ {
+ [alert addButtonWithTitle:@"Okay"];
+ } else if (type == 1)
+ {
+ [alert addButtonWithTitle:@"Okay"];
+ [alert addButtonWithTitle:@"Cancel"];
+ } else if (type == 2)
+ {
+ [alert addButtonWithTitle:@"Yes"];
+ [alert addButtonWithTitle:@"No"];
+ }
+ ret = [alert runModal];
}
- long ret = [alert runModal];
- [alert dealloc];
if (ret == NSAlertFirstButtonReturn)
{
diff --git a/indra/llwindow/llwindowmacosx.cpp b/indra/llwindow/llwindowmacosx.cpp
index c29131d60b..f924b17090 100644
--- a/indra/llwindow/llwindowmacosx.cpp
+++ b/indra/llwindow/llwindowmacosx.cpp
@@ -668,11 +668,11 @@ BOOL LLWindowMacOSX::createContext(int x, int y, int width, int height, int bits
if (cgl_err != kCGLNoError )
{
- LL_DEBUGS("GLInit") << "Multi-threaded OpenGL not available." << LL_ENDL;
+ LL_INFOS("GLInit") << "Multi-threaded OpenGL not available." << LL_ENDL;
}
else
{
- LL_DEBUGS("GLInit") << "Multi-threaded OpenGL enabled." << LL_ENDL;
+ LL_INFOS("GLInit") << "Multi-threaded OpenGL enabled." << LL_ENDL;
}
}
makeFirstResponder(mWindow, mGLView);
@@ -1246,8 +1246,11 @@ BOOL LLWindowMacOSX::isClipboardTextAvailable()
}
BOOL LLWindowMacOSX::pasteTextFromClipboard(LLWString &dst)
-{
- llutf16string str(copyFromPBoard());
+{
+ unsigned short* pboard_data = copyFromPBoard(); // must free returned data
+ llutf16string str(pboard_data);
+ free(pboard_data);
+
dst = utf16str_to_wstring(str);
if (dst != L"")
{
@@ -1280,7 +1283,7 @@ LLWindow::LLWindowResolution* LLWindowMacOSX::getSupportedResolutions(S32 &num_r
{
if (!mSupportedResolutions)
{
- CFArrayRef modes = CGDisplayAvailableModes(mDisplay);
+ CFArrayRef modes = CGDisplayCopyAllDisplayModes(mDisplay, nullptr);
if(modes != NULL)
{
@@ -1319,6 +1322,7 @@ LLWindow::LLWindowResolution* LLWindowMacOSX::getSupportedResolutions(S32 &num_r
}
}
}
+ CFRelease(modes);
}
}
diff --git a/indra/llwindow/llwindowmacosx.h b/indra/llwindow/llwindowmacosx.h
index b0f339e1db..851c860017 100644
--- a/indra/llwindow/llwindowmacosx.h
+++ b/indra/llwindow/llwindowmacosx.h
@@ -228,6 +228,7 @@ protected:
BOOL mLanguageTextInputAllowed;
LLPreeditor* mPreeditor;
+public:
static BOOL sUseMultGL;
friend class LLWindowManager;