Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorYevgeny Makarov <jenkm>2020-02-11 19:40:43 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2020-02-11 19:45:02 +0300
commit2fb928537104ec5a5060c29a6bc253906ff8a3dc (patch)
treecda6575203959acf45af65cb501d86e72ee12324 /intern
parent7b0aca2a530fb1a42367eebf595a1c6ca93dba7d (diff)
Fix T70039, T68707: issues when opening .blend file from Finder on macOS
* Missing close dialog displayed to warn about unsaved changes. * No reaction when the file was opened on a different desktop. Differential Revision: https://developer.blender.org/D6765
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm59
1 files changed, 20 insertions, 39 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 297b73f8b14..b65404cf9b1 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1366,10 +1366,17 @@ void GHOST_SystemCocoa::handleQuitRequest()
bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
{
NSString *filepath = (NSString *)filepathStr;
- bool confirmOpen = true;
NSArray *windowsList;
char *temp_buff;
size_t filenameTextSize;
+
+ /* Check for blender opened windows and make the frontmost key. In case blender
+ * is minimized, opened on another desktop space, or in full-screen mode. */
+ windowsList = [NSApp orderedWindows];
+ if ([windowsList count]) {
+ [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
+ }
+
GHOST_Window *window = (GHOST_Window *)m_windowManager->getActiveWindow();
if (!window) {
@@ -1377,51 +1384,25 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
}
/* Discard event if we are in cursor grab sequence,
- * it'll lead to "stuck cursor" situation if the alert panel is raised */
- if (window && window->getCursorGrabModeIsWarp())
+ * it'll lead to "stuck cursor" situation if the alert panel is raised. */
+ if (window && window->getCursorGrabModeIsWarp()) {
return NO;
-
- // Check open windows if some changes are not saved
- if (m_windowManager->getAnyModifiedState()) {
- @autoreleasepool {
- NSAlert *alert = [[NSAlert alloc] init];
- NSString *title = [NSString stringWithFormat:@"Opening %@", [filepath lastPathComponent]];
- NSString *text = @"Current document has not been saved.\nDo you really want to proceed?";
- [alert addButtonWithTitle:@"Open"];
- [alert addButtonWithTitle:@"Cancel"];
- [alert setMessageText:title];
- [alert setInformativeText:text];
- [alert setAlertStyle:NSAlertStyleInformational];
- confirmOpen = [alert runModal] == NSAlertFirstButtonReturn;
- }
- }
-
- // Give back focus to the blender window
- windowsList = [NSApp orderedWindows];
- if ([windowsList count]) {
- [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
}
- if (confirmOpen) {
- filenameTextSize = [filepath lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
-
- temp_buff = (char *)malloc(filenameTextSize + 1);
-
- if (temp_buff == NULL) {
- return GHOST_kFailure;
- }
+ filenameTextSize = [filepath lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
+ temp_buff = (char *)malloc(filenameTextSize + 1);
- strncpy(temp_buff, [filepath cStringUsingEncoding:NSUTF8StringEncoding], filenameTextSize);
+ if (temp_buff == NULL) {
+ return GHOST_kFailure;
+ }
- temp_buff[filenameTextSize] = '\0';
+ strncpy(temp_buff, [filepath cStringUsingEncoding:NSUTF8StringEncoding], filenameTextSize);
+ temp_buff[filenameTextSize] = '\0';
- pushEvent(new GHOST_EventString(
- getMilliSeconds(), GHOST_kEventOpenMainFile, window, (GHOST_TEventDataPtr)temp_buff));
+ pushEvent(new GHOST_EventString(
+ getMilliSeconds(), GHOST_kEventOpenMainFile, window, (GHOST_TEventDataPtr)temp_buff));
- return YES;
- }
- else
- return NO;
+ return YES;
}
GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventType)