changeset 6079:52393354c6dd

RT-4169: [Stage] Setting 'icons' to null do not reset the Stage icon Summary: The code to clean the icon in Glass was not being called by Quantum. When the code was called, there were problems in native glass on Mac and GTK that needed to be fixed. Reviewed-by: anthony
author snorthov
date Mon, 13 Jan 2014 15:51:59 -0500
parents 7e904aa338e1
children 2910f4be0016
files modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java modules/graphics/src/main/native-glass/gtk/GlassWindow.cpp modules/graphics/src/main/native-glass/mac/GlassWindow.m
diffstat 3 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Mon Jan 13 07:54:31 2014 -0800
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/WindowStage.java	Mon Jan 13 15:51:59 2014 -0500
@@ -302,6 +302,7 @@
         }
 
         if (icons == null || icons.size() < 1) { //no icons passed in
+            platformWindow.setIcon(null);
             return;
         }
 
--- a/modules/graphics/src/main/native-glass/gtk/GlassWindow.cpp	Mon Jan 13 07:54:31 2014 -0800
+++ b/modules/graphics/src/main/native-glass/gtk/GlassWindow.cpp	Mon Jan 13 15:51:59 2014 -0500
@@ -366,11 +366,13 @@
 {
     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
     GdkPixbuf *pixbuf = NULL;
-    env->CallVoidMethod(pixels, jPixelsAttachData, PTR_TO_JLONG(&pixbuf));
+    if (pixels != NULL) {
+        env->CallVoidMethod(pixels, jPixelsAttachData, PTR_TO_JLONG(&pixbuf));
+    }
     if (!EXCEPTION_OCCURED(env)) {
         ctx->set_icon(pixbuf);
     }
-    g_object_unref(pixbuf);
+    if (pixbuf != NULL) g_object_unref(pixbuf);
 }
 
 /*
--- a/modules/graphics/src/main/native-glass/mac/GlassWindow.m	Mon Jan 13 07:54:31 2014 -0800
+++ b/modules/graphics/src/main/native-glass/mac/GlassWindow.m	Mon Jan 13 15:51:59 2014 -0500
@@ -1322,14 +1322,12 @@
     GLASS_ASSERT_MAIN_JAVA_THREAD(env);
     GLASS_POOL_ENTER;
     {
+        GlassWindow *window = getGlassWindow(env, jPtr);
         if (jPixels != NULL)
         {
             NSImage *image = nil;
             (*env)->CallVoidMethod(env, jPixels, jPixelsAttachData, ptr_to_jlong(&image));
-            if (image != nil)
-            {
-                GlassWindow *window = getGlassWindow(env, jPtr);
-                
+            if (image != nil) {
                 // need an explicit window title for the rest of the code to work
                 if ([window->nsWindow title] == nil)
                 {
@@ -1340,7 +1338,11 @@
                 [window->nsWindow setRepresentedURL:[NSURL fileURLWithPath:[window->nsWindow title]]];
                 [[window->nsWindow standardWindowButton:NSWindowDocumentIconButton] setImage:image];
                 [image release];
+            } else {
+                [[window->nsWindow standardWindowButton:NSWindowDocumentIconButton] setImage:nil];
             }
+        } else {
+            [[window->nsWindow standardWindowButton:NSWindowDocumentIconButton] setImage:nil];
         }
     }
     GLASS_POOL_EXIT;