display, skin: remove some warnings 42/11742/2
authorGiWoong Kim <giwoong.kim@samsung.com>
Mon, 4 Nov 2013 03:06:47 +0000 (12:06 +0900)
committerGiWoong Kim <giwoong.kim@samsung.com>
Tue, 5 Nov 2013 08:43:07 +0000 (17:43 +0900)
1. added null pointer check
2. added unlock for exceptional path (maru_sdl.c)
3. added title for boilerplate (CustomScrollBar, CustomScrollBarComposite,
CustomScrollBarCompositeLayout.java)
4. define socket macro (maruskin_server.c)
5. minor modification, etc

Change-Id: Ibf79e407d259366c72b5f7b35e400694e276fb08
Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
18 files changed:
tizen/src/debug_ch.c
tizen/src/maru_finger.c
tizen/src/maru_sdl.c
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorFingers.java
tizen/src/skin/client/src/org/tizen/emulator/skin/EmulatorSdlSkin.java
tizen/src/skin/client/src/org/tizen/emulator/skin/comm/sock/SocketCommunicator.java
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrollBar.java
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledComposite.java
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/CustomScrolledCompositeLayout.java
tizen/src/skin/client/src/org/tizen/emulator/skin/custom/SpecialKeyWindow.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralKeyWindowImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/GeneralSkinImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/ImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/ProfileSkinImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/image/SpecialKeyWindowImageRegistry.java
tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java
tizen/src/skin/client/src/org/tizen/emulator/skin/menu/KeyWindowKeeper.java
tizen/src/skin/maruskin_server.c

index b794fb6..833b1ec 100644 (file)
@@ -481,9 +481,9 @@ int dbg_log(enum _debug_class cls, struct _debug_channel *channel,
         buf_time, debug_classes[cls], channel->name);
 
     if (*channel->multiname) {
-        ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, ":%s]", channel->multiname);
+        ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, ":%s] ", channel->multiname);
     } else {
-        ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, "]");
+        ret += snprintf(buf_msg + ret, sizeof(buf_msg) - ret, "] ");
     }
 
     va_start(valist, format);
index 975feb0..669e3fb 100644 (file)
@@ -186,13 +186,14 @@ void init_multi_touch_state(void)
         mts->finger_slot = NULL;
     }
     mts->finger_slot =
-        (FingerPoint *)g_malloc0(sizeof(FingerPoint) * mts->finger_cnt_max);
+        (FingerPoint *) g_malloc0(sizeof(FingerPoint) * mts->finger_cnt_max);
 
     for (i = 0; i < mts->finger_cnt_max; i++) {
         finger = get_finger_point_from_slot(i);
-        //finger->id = 0;
-        finger->origin_x = finger->origin_y = -1;
-        finger->x = finger->y = -1;
+        if (finger != NULL) {
+            finger->origin_x = finger->origin_y = -1;
+            finger->x = finger->y = -1;
+        }
     }
 
     mts->finger_point_size = DEFAULT_FINGER_POINT_SIZE;
index 80ab8fd..28e4f85 100644 (file)
@@ -678,13 +678,13 @@ static void maru_sdl_resize_bh(void *opaque)
     INFO("Set up a video mode with the specified width, "
          "height and bits-per-pixel\n");
 
+    sdl_alteration = 1;
+    sdl_skip_update = 0;
+
 #ifdef SDL_THREAD
     pthread_mutex_lock(&sdl_mutex);
 #endif
 
-    sdl_alteration = 1;
-    sdl_skip_update = 0;
-
     /* get current setting information and calculate screen size */
     display_width = get_emul_lcd_width();
     display_height = get_emul_lcd_height();
@@ -720,6 +720,11 @@ static void maru_sdl_resize_bh(void *opaque)
         ERR("Could not open SDL display (%dx%dx%d) : %s\n",
             surface_width, surface_height,
             get_emul_sdl_bpp(), SDL_GetError());
+
+#ifdef SDL_THREAD
+        pthread_mutex_unlock(&sdl_mutex);
+#endif
+
         return;
     }
 
@@ -837,12 +842,12 @@ void maruskin_sdl_quit(void)
         qemu_bh_delete(sdl_resize_bh);
     }
 
+    sdl_alteration = -1;
+
 #ifdef SDL_THREAD
     pthread_mutex_lock(&sdl_mutex);
 #endif
 
-    sdl_alteration = -1;
-
     SDL_Quit();
 
 #ifdef SDL_THREAD
index 866228b..05b21c0 100644 (file)
@@ -84,7 +84,7 @@ public class EmulatorFingers {
                initMultiTouchState(maximum);
        }
 
-       class FingerPoint {
+       static class FingerPoint {
                private int id;
                private int originX;
                private int originY;
index 0d90b30..76375a6 100644 (file)
@@ -66,7 +66,6 @@ public class EmulatorSdlSkin extends EmulatorSkin {
 
                /* org.eclipse.swt.widgets.Widget */
                if (SwtUtil.isLinuxPlatform()) {
-
                        try {
                                Field field = lcdCanvas.getClass().getField("embeddedHandle");
                                windowHandleId = field.getLong(lcdCanvas);
@@ -84,9 +83,7 @@ public class EmulatorSdlSkin extends EmulatorSkin {
                                logger.log(Level.SEVERE, e.getMessage(), e);
                                shutdown();
                        }
-
                } else if (SwtUtil.isWindowsPlatform()) {
-
                        try {
                                Field field = lcdCanvas.getClass().getField("handle");
                                windowHandleId = field.getLong(lcdCanvas);
@@ -104,15 +101,10 @@ public class EmulatorSdlSkin extends EmulatorSkin {
                                logger.log(Level.SEVERE, e.getMessage(), e);
                                shutdown();
                        }
-
-               } else if (SwtUtil.isMacPlatform()) {
-
-                       // not supported
-                       windowHandleId = 0;
-
                } else {
+                       /* not supported */
                        logger.severe("Not Supported OS platform:" + SWT.getPlatform());
-                       System.exit(-1);
+                       shutdown();
                }
 
                return windowHandleId;
index 2ead9b2..1b51411 100755 (executable)
@@ -65,7 +65,7 @@ import org.tizen.emulator.skin.util.SkinUtil;
  * 
  */
 public class SocketCommunicator implements ICommunicator {
-       public class DataTranfer {
+       public static class DataTranfer {
                private boolean isTransferState;
                private byte[] receivedData;
 
@@ -572,16 +572,16 @@ public class SocketCommunicator implements ICommunicator {
        }
        
        private void sendToQEMUInternal(SkinSendData sendData) {
-               try {
-                       if (null == sendData) {
-                               return;
-                       }
-                       
-                       SendCommand command = sendData.getCommand();
-                       ISendData data = sendData.getSendData();
+               if (null == sendData) {
+                       return;
+               }
+
+               SendCommand command = sendData.getCommand();
+               ISendData data = sendData.getSendData();
 
-                       reqId = (Integer.MAX_VALUE == reqId) ? 0 : ++reqId;
+               reqId = (Integer.MAX_VALUE == reqId) ? 0 : ++reqId;
 
+               try {
                        dataOutputStream.writeInt(uId);
                        dataOutputStream.writeInt(reqId);
                        dataOutputStream.writeShort(command.value());
@@ -615,11 +615,9 @@ public class SocketCommunicator implements ICommunicator {
                                        logger.fine("[Socket] data  - " + data.toString());
                                }
                        }
-
                } catch (IOException e) {
                        logger.log(Level.SEVERE, e.getMessage(), e);
                }
-
        }
 
        public byte[] getReceivedData(DataTranfer dataTranfer) {
@@ -714,10 +712,8 @@ public class SocketCommunicator implements ICommunicator {
 
                isTerminated = true;
 
-               if (null != sendQueue) {
-                       synchronized (sendQueue) {
-                               sendQueue.notifyAll();
-                       }
+               synchronized (sendQueue) {
+                       sendQueue.notifyAll();
                }
 
                if (null != heartbeatTimer) {
index 93a1708..dcbd942 100644 (file)
@@ -1,5 +1,5 @@
 /**
- *
+ * Custom Scroll Bar
  *
  * Copyright (C) 2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
@@ -189,9 +189,9 @@ public class CustomScrollBar {
                                        /* draw a thumb */
                                        int heightScrollGap = compositeScroll.getMinHeight() - heightScrollBar;
 
-                                       float tempHeightThumb = (compositeScroll.getMinHeight() - heightScrollGap) *
+                                       int tempHeightThumb = (compositeScroll.getMinHeight() - heightScrollGap) *
                                                        dataShaft.heightShaft / compositeScroll.getMinHeight();
-                                       dataThumb.boundsThumb.height = Math.max(1, (int)tempHeightThumb);
+                                       dataThumb.boundsThumb.height = Math.max(1, tempHeightThumb);
 
                                        dataThumb.boundsThumb.x = 2;
                                        dataThumb.boundsThumb.y = getSelection() *
@@ -328,11 +328,11 @@ public class CustomScrollBar {
                                if (dataThumb.isGrabbed == true) {
                                        int yDragged = e.y - dataThumb.yGrabPosition;
 
-                                       float yDraggedScale = yDragged *
+                                       int yDraggedScale = yDragged *
                                                        (compositeScroll.getMinHeight() - heightScrollBar) /
                                                        (dataShaft.heightShaft - dataThumb.boundsThumb.height);
 
-                                       setSelection(dataThumb.yGrabSelection + (int)yDraggedScale);
+                                       setSelection(dataThumb.yGrabSelection + yDraggedScale);
                                        updateScrollbar();
                                }
                        }
index 40b9fca..46e545b 100644 (file)
@@ -272,22 +272,22 @@ public class SpecialKeyWindow extends SkinWindow {
                shellMouseMoveListener = new MouseMoveListener() {
                        @Override
                        public void mouseMove(MouseEvent e) {
-                               if (isTouch == true) {                                  
+                               if (isTouch == true) {
                                        logger.info("mouseMove in KeyWindow : " + e.x + ", " + e.y);
 
-                                       HWKey pressedHWKey = currentPressedHWKey;                                       
+                                       HWKey pressedHWKey = currentPressedHWKey;
                                        int x = pressedHWKey.getRegion().x;
                                        int y = pressedHWKey.getRegion().y;
                                        int width = pressedHWKey.getRegion().width;
                                        int height = pressedHWKey.getRegion().height;
-                                       int eventType;
+                                       //int eventType;
 
                                        if (SkinUtil.isInGeometry(e.x, e.y, x, y, width, height)) {
-                                               eventType = MouseEventType.DRAG.value();
+                                               //eventType = MouseEventType.DRAG.value();
                                        } else {
                                                isTouch = false;
-                                               eventType = MouseEventType.RELEASE.value();
-                                               /* rollback a keyPressed image resion */
+                                               //eventType = MouseEventType.RELEASE.value();
+                                               /* rollback a keyPressed image region */
                                                shell.redraw(x, y, width, height, false);
                                        }
 
index 7aef8b9..5c5b4f2 100644 (file)
@@ -132,7 +132,9 @@ public class GeneralKeyWindowImageRegistry {
 
                        while (imageIterator.hasNext()) {
                                image = imageIterator.next();
-                               image.dispose();
+                               if (image != null) {
+                                       image.dispose();
+                               }
                        }
                }
        }
index 158ce6c..5248adf 100644 (file)
@@ -123,7 +123,9 @@ public class GeneralSkinImageRegistry {
 
                        while (imageIterator.hasNext()) {
                                image = imageIterator.next();
-                               image.dispose();
+                               if (image != null) {
+                                       image.dispose();
+                               }
                        }
                }
        }
index 62a1058..d61f9f0 100644 (file)
@@ -224,7 +224,9 @@ public class ImageRegistry {
 
                        while (imageIterator.hasNext()) {
                                image = imageIterator.next();
-                               image.dispose();
+                               if (image != null) {
+                                       image.dispose();
+                               }
                        }
                }
        }
index 84e81ac..9690504 100644 (file)
@@ -129,7 +129,9 @@ public class ProfileSkinImageRegistry {
 
                        while (imageIterator.hasNext()) {
                                image = imageIterator.next();
-                               image.dispose();
+                               if (image != null) {
+                                       image.dispose();
+                               }
                        }
                }
        }
index adcf4d9..dfe5b6f 100644 (file)
@@ -116,7 +116,9 @@ public class SpecialKeyWindowImageRegistry {
 
                        while (imageIterator.hasNext()) {
                                image = imageIterator.next();
-                               image.dispose();
+                               if (image != null) {
+                                       image.dispose();
+                               }
                        }
                }
        }
index 2258bea..a6b066c 100644 (file)
@@ -112,9 +112,11 @@ public class SkinLogger {
                        }
 
                        File dir = new File(path + LOG_FOLDER);
-                       dir.mkdir();
+                       if (dir.mkdir() == false) {
+                               /* do nothing */
+                       }
 
-                       /* delete .lck files after abnomal skin termination */
+                       /* delete .lck files after abnormal skin termination */
                        File[] listFiles = dir.listFiles();
                        for (File f : listFiles) {
                                String name = f.getName();
index 66e0e44..c4cd217 100644 (file)
@@ -86,7 +86,8 @@ public class KeyWindowKeeper {
                /* create a Key Window */
                determineLayout();
 
-               if (isGeneralKeyWindow() == true) {
+               if (isGeneralKeyWindow() == true
+                               || skin.getPopupMenu().keyWindowItem.getMenu() == null) {
                        if (imageRegstry == null) {
                                logger.warning("GeneralKeyWindowImageRegistry is null");
                                return;
@@ -96,12 +97,14 @@ public class KeyWindowKeeper {
                                        skin.getEmulatorSkinState().getCurrentRotationId());
 
                        if (keyMapList == null) {
-                               selectKeyWindowMenu(skin.isKeyWindow = false);
                                logger.info("keyMapList is null");
+
+                               selectKeyWindowMenu(skin.isKeyWindow = false);
                                return;
                        } else if (keyMapList.isEmpty() == true) {
-                               selectKeyWindowMenu(skin.isKeyWindow = false);
                                logger.info("keyMapList is empty");
+
+                               selectKeyWindowMenu(skin.isKeyWindow = false);
                                return;
                        }
 
@@ -196,15 +199,19 @@ public class KeyWindowKeeper {
 
        /* for Menu */
        public boolean isSelectKeyWindowMenu() {
-               MenuItem keywindow = skin.getPopupMenu().keyWindowItem;
+               MenuItem keywindowMenu = skin.getPopupMenu().keyWindowItem;
 
-               if (keywindow != null) {
+               if (keywindowMenu != null) {
                        if (isGeneralKeyWindow() == true) {
-                               return keywindow.getSelection();
+                               return keywindowMenu.getSelection();
                        } else {
-                               for (MenuItem layout : keywindow.getMenu().getItems()) {
-                                       if (layout.getSelection() == true) {
-                                               return true;
+                               if (keywindowMenu.getMenu() == null) {
+                                       logger.info("Special KeyWindow menu item is null");
+                               } else {
+                                       for (MenuItem layout : keywindowMenu.getMenu().getItems()) {
+                                               if (layout.getSelection() == true) {
+                                                       return true;
+                                               }
                                        }
                                }
                        }
@@ -214,13 +221,17 @@ public class KeyWindowKeeper {
        }
 
        public void selectKeyWindowMenu(boolean on) {
-               MenuItem keywindow = skin.getPopupMenu().keyWindowItem;
+               MenuItem keywindowMenu = skin.getPopupMenu().keyWindowItem;
 
-               if (keywindow != null) {
+               if (keywindowMenu != null) {
                        if (isGeneralKeyWindow() == true) {
-                               keywindow.setSelection(on);
+                               keywindowMenu.setSelection(on);
                        } else {
-                               keywindow.getMenu().getItem(indexLayout).setSelection(on);
+                               if (keywindowMenu.getMenu() == null) {
+                                       logger.info("Special KeyWindow menu item is null");
+                               } else {
+                                       keywindowMenu.getMenu().getItem(indexLayout).setSelection(on);
+                               }
                        }
                }
        }
index 2a816fe..b04d937 100644 (file)
 #include <winsock2.h>
 #include <ws2tcpip.h>
 
-#define socket_error() WSAGetLastError()
+#define SLEEP(x) Sleep(x)
+#define SOCKET_CLOSE(sock) closesocket(sock)
+#define SOCKET_ERROR() WSAGetLastError()
 #else
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
 
-#define socket_error() errno
+#define SLEEP(x) usleep(x * 1000)
+#define SOCKET_CLOSE(sock) close(sock)
+#define SOCKET_ERROR() errno
 #endif
 
 #include "debug_ch.h"
@@ -242,11 +246,8 @@ void shutdown_skin_server(void)
                 INFO("skin client sent normal shutdown response.\n");
                 break;
             } else {
-#ifdef CONFIG_WIN32
-                Sleep(1); /* 1ms */
-#else
-                usleep(1000);
-#endif
+                SLEEP(1); /* 1ms */
+
                 count++;
             }
         }
@@ -259,22 +260,16 @@ void shutdown_skin_server(void)
     is_force_close_client = 1;
 
     if (client_sock) {
-#ifdef CONFIG_WIN32
-        closesocket(client_sock);
-#else
-        close(client_sock);
-#endif
+        SOCKET_CLOSE(client_sock);
+
         client_sock = 0;
     }
 
     if (close_server_socket) {
         INFO("skin client did not send normal shutdown response.\n");
         if (server_sock) {
-#ifdef CONFIG_WIN32
-            closesocket(server_sock);
-#else
-            close(server_sock);
-#endif
+            SOCKET_CLOSE(server_sock);
+
             server_sock = 0;
         }
     }
@@ -398,11 +393,7 @@ void notify_booting_progress(unsigned int layer, int progress_value)
             ERR("fail to send SEND_BOOTING_PROGRESS to skin.\n");
         }
 
-#ifdef CONFIG_WIN32
-        Sleep(1); /* 1ms */
-#else
-        usleep(1000);
-#endif
+        SLEEP(1); /* 1ms */
     } else {
         INFO("skin client socket is not connected yet\n");
     }
@@ -606,11 +597,8 @@ static void* run_skin_server(void* args)
         perror("skin server bind error : ");
 
         if (server_sock) {
-#ifdef CONFIG_WIN32
-            closesocket(server_sock);
-#else
-            close(server_sock);
-#endif
+            SOCKET_CLOSE(server_sock);
+
             server_sock = 0;
         }
 
@@ -637,11 +625,8 @@ static void* run_skin_server(void* args)
         perror("skin_server listen error : ");
 
         if (server_sock) {
-#ifdef CONFIG_WIN32
-            closesocket(server_sock);
-#else
-            close(server_sock);
-#endif
+            SOCKET_CLOSE(server_sock);
+
             server_sock = 0;
         }
 
@@ -674,6 +659,10 @@ static void* run_skin_server(void* args)
             }
         }
 
+        if (client_sock != 0) {
+            SOCKET_CLOSE(client_sock);
+        }
+
         INFO("start accepting socket...\n");
 
         if (0 > (client_sock = accept(
@@ -704,7 +693,7 @@ static void* run_skin_server(void* args)
                     is_force_close_client = 0;
                 } else {
                     ERR("skin_server read error (%d): %d\n",
-                        socket_error(), read_cnt);
+                        SOCKET_ERROR(), read_cnt);
                     perror("skin_server read error : ");
                 }
 
@@ -1088,36 +1077,31 @@ static void* run_skin_server(void* args)
                     break;
                 }
                 case RECV_RESPONSE_SHUTDOWN: {
-                    log_cnt += sprintf( log_buf + log_cnt, "RECV_RESPONSE_SHUTDOWN ==\n" );
-                    INFO( log_buf );
+                    log_cnt += sprintf(log_buf + log_cnt, "RECV_RESPONSE_SHUTDOWN ==\n");
+                    INFO(log_buf);
 
                     stop_server = 1;
                     break;
                 }
                 default: {
-                    log_cnt += sprintf( log_buf + log_cnt, "!!! unknown command : %d\n", cmd );
-                    TRACE( log_buf );
+                    log_cnt += sprintf(log_buf + log_cnt, "!!! unknown command : %d\n", cmd);
+                    TRACE(log_buf);
 
-                    ERR( "!!! unknown command : %d\n", cmd );
+                    ERR("!!! unknown command : %d\n", cmd);
                     break;
                 }
                 }
-
             }
 
-        }
-
-    }
+        } /* end of while */
+    } /* end of while */
 
     stop_heart_beat();
 
     /* clean up */
     if (server_sock) {
-#ifdef CONFIG_WIN32
-        closesocket(server_sock);
-#else
-        close(server_sock);
-#endif
+        SOCKET_CLOSE(server_sock);
+
         server_sock = 0;
     }
 
@@ -1298,17 +1282,9 @@ static void* do_heart_beat(void* args)
         if (booting_handicap_cnt < 5) {
             booting_handicap_cnt++;
 
-#ifdef CONFIG_WIN32
-            Sleep(hb_interval * 10); /* 10sec */
-#else
-            usleep(hb_interval * 1000 * 10);
-#endif
+            SLEEP(hb_interval * 10); /* 10sec */
         } else {
-#ifdef CONFIG_WIN32
-            Sleep(hb_interval); /* 1sec */
-#else
-            usleep(hb_interval * 1000);
-#endif
+            SLEEP(hb_interval); /* 1sec */
         }
 
         if (stop_heartbeat) {
@@ -1359,22 +1335,16 @@ static void* do_heart_beat(void* args)
         is_force_close_client = 1;
 
         if (client_sock) {
-#ifdef CONFIG_WIN32
-            closesocket(client_sock);
-#else
-            close(client_sock);
-#endif
+            SOCKET_CLOSE(client_sock);
+
             client_sock = 0;
         }
 
         stop_server = 1;
 
         if (server_sock) {
-#ifdef CONFIG_WIN32
-            closesocket(server_sock);
-#else
-            close(server_sock);
-#endif
+            SOCKET_CLOSE(server_sock);
+
             server_sock = 0;
         }
 
@@ -1409,5 +1379,7 @@ static int start_heart_beat(void)
 
 static void stop_heart_beat(void)
 {
+    INFO("stop the heart beat signal\n");
+
     stop_heartbeat = 1;
 }