From f6251a1f321d9c35b924bd88b2b786cce035071d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 17 Sep 2012 22:34:42 +0000 Subject: [PATCH] code cleanup: warning and style --- intern/ghost/intern/GHOST_SystemCocoa.mm | 55 +++++++++++-------- intern/ghost/intern/GHOST_WindowCocoa.mm | 6 +- intern/ghost/test/multitest/EventToBuf.c | 3 +- intern/memutil/MEM_CacheLimiter.h | 13 +++-- source/blender/editors/space_file/file_ops.c | 2 +- source/blender/editors/space_file/fsmenu.c | 3 +- .../windowmanager/intern/wm_playanim.c | 8 --- 7 files changed, 49 insertions(+), 41 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 7bc40287dc3..76ebdcc07e0 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -355,16 +355,18 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction) /* alphanumerical or punctuation key that is remappable in int'l keyboards */ if ((recvChar >= 'A') && (recvChar <= 'Z')) { return (GHOST_TKey) (recvChar - 'A' + GHOST_kKeyA); - } else if ((recvChar >= 'a') && (recvChar <= 'z')) { + } + else if ((recvChar >= 'a') && (recvChar <= 'z')) { return (GHOST_TKey) (recvChar - 'a' + GHOST_kKeyA); - } else { + } + else { #if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 KeyboardLayoutRef keyLayout; UCKeyboardLayout *uchrData; KLGetCurrentKeyboardLayout(&keyLayout); KLGetKeyboardLayoutProperty(keyLayout, kKLuchrData, (const void **) - &uchrData); + &uchrData); /*get actual character value of the "remappable" keys in int'l keyboards, if keyboard layout is not correctly reported (e.g. some non Apple keyboards in Tiger), then fallback on using the received charactersIgnoringModifiers */ @@ -870,29 +872,30 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) // SetMouseCoalescingEnabled(false, NULL); //TODO : implement timer ?? - - /*do { +#if 0 + do { GHOST_TimerManager* timerMgr = getTimerManager(); if (waitForEvent) { - GHOST_TUns64 next = timerMgr->nextFireTime(); - double timeOut; + GHOST_TUns64 next = timerMgr->nextFireTime(); + double timeOut; - if (next == GHOST_kFireTimeNever) { - timeOut = kEventDurationForever; - } else { - timeOut = (double)(next - getMilliSeconds())/1000.0; - if (timeOut < 0.0) - timeOut = 0.0; - } + if (next == GHOST_kFireTimeNever) { + timeOut = kEventDurationForever; + } + else { + timeOut = (double)(next - getMilliSeconds())/1000.0; + if (timeOut < 0.0) + timeOut = 0.0; + } - ::ReceiveNextEvent(0, NULL, timeOut, false, &event); + ::ReceiveNextEvent(0, NULL, timeOut, false, &event); } if (timerMgr->fireTimers(getMilliSeconds())) { - anyProcessed = true; + anyProcessed = true; } - */ +#endif do { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; @@ -963,7 +966,9 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent) [NSApp sendEvent:event]; [pool drain]; } while (event!= nil); - //} while (waitForEvent && !anyProcessed); Needed only for timer implementation +#if 0 + } while (waitForEvent && !anyProcessed); // Needed only for timer implementation +#endif if (m_needDelayedApplicationBecomeActiveEventProcessing) handleApplicationBecomeActiveEvent(); @@ -1285,12 +1290,13 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest() if (m_windowManager->getAnyModifiedState()) { int shouldQuit = NSRunAlertPanel(@"Exit Blender", @"Some changes have not been saved.\nDo you really want to quit ?", - @"Cancel", @"Quit Anyway", nil); + @"Cancel", @"Quit Anyway", nil); if (shouldQuit == NSAlertAlternateReturn) { pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL) ); return GHOST_kExitNow; - } else { + } + else { //Give back focus to the blender window if user selected cancel quit NSArray *windowsList = [NSApp orderedWindows]; if ([windowsList count]) { @@ -1405,7 +1411,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventT ct.Active = GHOST_kTabletModeNone; break; } - } else { + } + else { // pointer is leaving - return to mouse ct.Active = GHOST_kTabletModeNone; } @@ -1694,7 +1701,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr) if ([event type] == NSKeyDown) { pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii, utf8_buf) ); //printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf); - } else { + } + else { pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, 0, '\0') ); //printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf); } @@ -1780,7 +1788,8 @@ GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const if(temp_buff) { return temp_buff; - } else { + } + else { return NULL; } } diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 31589003131..dc05fe42a70 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -670,7 +670,8 @@ void GHOST_WindowCocoa::setTitle(const STR_String& title) [m_window setRepresentedFilename:@""]; } - } else { + } + else { [m_window setTitle:windowTitle]; [m_window setRepresentedFilename:@""]; } @@ -1288,7 +1289,8 @@ void GHOST_WindowCocoa::loadCursor(bool visible, GHOST_TStandardCursor cursor) c if (cursor == GHOST_kStandardCursorCustom && m_customCursor) { tmpCursor = m_customCursor; - } else { + } + else { switch (cursor) { case GHOST_kStandardCursorDestroy: tmpCursor = [NSCursor disappearingItemCursor]; diff --git a/intern/ghost/test/multitest/EventToBuf.c b/intern/ghost/test/multitest/EventToBuf.c index 0eb37a58be2..aba80784a72 100644 --- a/intern/ghost/test/multitest/EventToBuf.c +++ b/intern/ghost/test/multitest/EventToBuf.c @@ -208,7 +208,8 @@ void event_to_buf(GHOST_EventHandle evt, char buf[128]) char *s= GHOST_GetTitle(win); pos += sprintf(pos, " - win: %s", s); free(s); - } else { + } + else { pos+= sprintf(pos, " - sys evt"); } switch (type) { diff --git a/intern/memutil/MEM_CacheLimiter.h b/intern/memutil/MEM_CacheLimiter.h index 801ee154d40..1f1088ea118 100644 --- a/intern/memutil/MEM_CacheLimiter.h +++ b/intern/memutil/MEM_CacheLimiter.h @@ -179,9 +179,10 @@ public: return; } - if(getDataSize) { + if (getDataSize) { mem_in_use = total_size(); - } else { + } + else { mem_in_use = MEM_get_memory_in_use(); } @@ -196,16 +197,18 @@ public: priority_queue.pop(); - if(getDataSize) { + if (getDataSize) { cur_size = getDataSize(elem->get()->get_data()); - } else { + } + else { cur_size = mem_in_use; } if (elem->destroy_if_possible()) { if (getDataSize) { mem_in_use -= cur_size; - } else { + } + else { mem_in_use -= cur_size - MEM_get_memory_in_use(); } } diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 6c718751cfe..94967b264ed 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -515,7 +515,7 @@ void FILE_OT_delete_bookmark(wmOperatorType *ot) RNA_def_int(ot->srna, "index", -1, -1, 20000, "Index", "", -1, 20000); } -static int reset_recent_exec(bContext *C, wmOperator *op) +static int reset_recent_exec(bContext *C, wmOperator *UNUSED(op)) { ScrArea *sa = CTX_wm_area(C); char name[FILE_MAX]; diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index f7701e79016..66cda3082ea 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -206,7 +206,8 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, FSMenuCategory category, const c if (flag & FS_INSERT_FIRST) { fsm_iter->next = fsm_head; fsmenu_set_category(fsmenu, category, fsm_iter); - } else { + } + else { fsm_iter->next = fsm_prev->next; fsm_prev->next = fsm_iter; } diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index bff40faf1d1..35cc1545c40 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -713,14 +713,6 @@ static void playanim_window_open(const char *title, int posx, int posy, int size inital_state, GHOST_kDrawingContextTypeOpenGL, FALSE /* no stereo */, FALSE); - - //if (ghostwin) { - //if (win) { - // GHOST_SetWindowUserData(ghostwin, win); - //} else { - // GHOST_DisposeWindow(g_WS.ghost_system, ghostwin); - //} - //} }