diff --git a/Common/LogManager.cpp b/Common/LogManager.cpp index b8391f7502..f237de1ca3 100644 --- a/Common/LogManager.cpp +++ b/Common/LogManager.cpp @@ -132,8 +132,7 @@ LogManager::LogManager() { LogManager::~LogManager() { for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; ++i) { #if !defined(MOBILE_DEVICE) || defined(_DEBUG) - if (fileLog_ != NULL) - RemoveListener(fileLog_); + RemoveListener(fileLog_); RemoveListener(consoleLog_); #if defined(_MSC_VER) && defined(USING_WIN_UI) RemoveListener(debuggerLog_); @@ -257,11 +256,15 @@ void LogManager::Shutdown() { } void LogManager::AddListener(LogListener *listener) { + if (!listener) + return; std::lock_guard lk(listeners_lock_); listeners_.push_back(listener); } void LogManager::RemoveListener(LogListener *listener) { + if (!listener) + return; std::lock_guard lk(listeners_lock_); auto iter = std::find(listeners_.begin(), listeners_.end(), listener); if (iter != listeners_.end()) diff --git a/Core/Util/BlockAllocator.cpp b/Core/Util/BlockAllocator.cpp index 2d7e5e67f5..6c14dfe2b1 100644 --- a/Core/Util/BlockAllocator.cpp +++ b/Core/Util/BlockAllocator.cpp @@ -59,7 +59,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromT { // Sanity check if (size == 0 || size > rangeSize_) { - ERROR_LOG(HLE, "Clearly bogus size: %08x - failing allocation", size); + ERROR_LOG(SCEKERNEL, "Clearly bogus size: %08x - failing allocation", size); return -1; } @@ -137,7 +137,7 @@ u32 BlockAllocator::AllocAligned(u32 &size, u32 sizeGrain, u32 grain, bool fromT //Out of memory :( ListBlocks(); - ERROR_LOG(HLE, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, size, size); + ERROR_LOG(SCEKERNEL, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, size, size); return -1; } @@ -151,7 +151,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) { CheckBlocks(); if (size > rangeSize_) { - ERROR_LOG(HLE, "Clearly bogus size: %08x - failing allocation", size); + ERROR_LOG(SCEKERNEL, "Clearly bogus size: %08x - failing allocation", size); return -1; } @@ -159,7 +159,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) u32 alignedPosition = position; u32 alignedSize = size; if (position & (grain_ - 1)) { - DEBUG_LOG(HLE, "Position %08x does not align to grain.", position); + DEBUG_LOG(SCEKERNEL, "Position %08x does not align to grain.", position); alignedPosition &= ~(grain_ - 1); // Since the position was decreased, size must increase. @@ -177,7 +177,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) Block &b = *bp; if (b.taken) { - ERROR_LOG(HLE, "Block allocator AllocAt failed, block taken! %08x, %i", position, size); + ERROR_LOG(SCEKERNEL, "Block allocator AllocAt failed, block taken! %08x, %i", position, size); return -1; } else @@ -185,7 +185,7 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) // Make sure the block is big enough to split. if (b.start + b.size < alignedPosition + alignedSize) { - ERROR_LOG(HLE, "Block allocator AllocAt failed, not enough contiguous space %08x, %i", position, size); + ERROR_LOG(SCEKERNEL, "Block allocator AllocAt failed, not enough contiguous space %08x, %i", position, size); return -1; } //good to go @@ -212,24 +212,24 @@ u32 BlockAllocator::AllocAt(u32 position, u32 size, const char *tag) } else { - ERROR_LOG(HLE, "Block allocator AllocAt failed :( %08x, %i", position, size); + ERROR_LOG(SCEKERNEL, "Block allocator AllocAt failed :( %08x, %i", position, size); } //Out of memory :( ListBlocks(); - ERROR_LOG(HLE, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, alignedSize, alignedSize); + ERROR_LOG(SCEKERNEL, "Block Allocator (%08x-%08x) failed to allocate %i (%08x) bytes of contiguous memory", rangeStart_, rangeStart_ + rangeSize_, alignedSize, alignedSize); return -1; } void BlockAllocator::MergeFreeBlocks(Block *fromBlock) { - DEBUG_LOG(HLE, "Merging Blocks"); + DEBUG_LOG(SCEKERNEL, "Merging Blocks"); Block *prev = fromBlock->prev; while (prev != NULL && prev->taken == false) { - DEBUG_LOG(HLE, "Block Alloc found adjacent free blocks - merging"); + DEBUG_LOG(SCEKERNEL, "Block Alloc found adjacent free blocks - merging"); prev->size += fromBlock->size; if (fromBlock->next == NULL) top_ = prev; @@ -249,7 +249,7 @@ void BlockAllocator::MergeFreeBlocks(Block *fromBlock) Block *next = fromBlock->next; while (next != NULL && next->taken == false) { - DEBUG_LOG(HLE, "Block Alloc found adjacent free blocks - merging"); + DEBUG_LOG(SCEKERNEL, "Block Alloc found adjacent free blocks - merging"); fromBlock->size += next->size; fromBlock->next = next->next; delete next; @@ -273,7 +273,7 @@ bool BlockAllocator::Free(u32 position) } else { - ERROR_LOG(HLE, "BlockAllocator : invalid free %08x", position); + ERROR_LOG(SCEKERNEL, "BlockAllocator : invalid free %08x", position); return false; } } @@ -289,7 +289,7 @@ bool BlockAllocator::FreeExact(u32 position) } else { - ERROR_LOG(HLE, "BlockAllocator : invalid free %08x", position); + ERROR_LOG(SCEKERNEL, "BlockAllocator : invalid free %08x", position); return false; } } @@ -389,13 +389,13 @@ u32 BlockAllocator::GetBlockSizeFromAddress(u32 addr) const void BlockAllocator::ListBlocks() const { - INFO_LOG(HLE,"-----------"); + INFO_LOG(SCEKERNEL,"-----------"); for (const Block *bp = bottom_; bp != NULL; bp = bp->next) { const Block &b = *bp; - INFO_LOG(HLE, "Block: %08x - %08x size %08x taken=%i tag=%s", b.start, b.start+b.size, b.size, b.taken ? 1:0, b.tag); + INFO_LOG(SCEKERNEL, "Block: %08x - %08x size %08x taken=%i tag=%s", b.start, b.start+b.size, b.size, b.taken ? 1:0, b.tag); } - INFO_LOG(HLE,"-----------"); + INFO_LOG(SCEKERNEL,"-----------"); } u32 BlockAllocator::GetLargestFreeBlockSize() const diff --git a/ext/native/base/logging.cpp b/ext/native/base/logging.cpp new file mode 100644 index 0000000000..b4f40fa8c7 --- /dev/null +++ b/ext/native/base/logging.cpp @@ -0,0 +1,9 @@ +#include "base/logging.h" + +const char *GetFn(const char *fn) { + const char *p = strrchr(fn, '\\'); + if (p) + return p + 1; + else + return fn; +} diff --git a/ext/native/base/logging.h b/ext/native/base/logging.h index bea7bb5356..2054ae5d98 100644 --- a/ext/native/base/logging.h +++ b/ext/native/base/logging.h @@ -74,10 +74,12 @@ void OutputDebugStringUTF8(const char *p); #ifdef _WIN32 +const char *GetFn(const char *fn); + #define XLOG_IMPL(type, ...) do {\ char temp[512]; \ char *p = temp; \ - int len = snprintf(p, sizeof(temp), type ": %s:%i: ", __FILE__, __LINE__); \ + int len = snprintf(p, sizeof(temp), type ": %s:%i: ", GetFn(__FILE__), __LINE__); \ if (len < sizeof(temp)) { \ p += len; \ p += snprintf(p, sizeof(temp) - len - 3, type ": " __VA_ARGS__); \ diff --git a/ext/native/native.vcxproj b/ext/native/native.vcxproj index 54c7423513..ee37838e7b 100644 --- a/ext/native/native.vcxproj +++ b/ext/native/native.vcxproj @@ -293,6 +293,7 @@ + true true diff --git a/ext/native/native.vcxproj.filters b/ext/native/native.vcxproj.filters index 1c26754b7c..71002e0a4a 100644 --- a/ext/native/native.vcxproj.filters +++ b/ext/native/native.vcxproj.filters @@ -763,6 +763,9 @@ thin3d + + base + diff --git a/ext/native/ui/viewgroup.cpp b/ext/native/ui/viewgroup.cpp index 48fe328395..bfc42b7ce0 100644 --- a/ext/native/ui/viewgroup.cpp +++ b/ext/native/ui/viewgroup.cpp @@ -1128,6 +1128,19 @@ TabHolder::TabHolder(Orientation orientation, float stripSize, LayoutParams *lay tabStrip_->OnChoice.Handle(this, &TabHolder::OnTabClick); } +void TabHolder::SetCurrentTab(int tab) { + if (tab >= (int)tabs_.size()) { + // Ignore + return; + } + if (tab != currentTab_) { + tabs_[currentTab_]->SetVisibility(V_GONE); + currentTab_ = tab; + tabs_[currentTab_]->SetVisibility(V_VISIBLE); + } + tabStrip_->SetSelection(tab); +} + EventReturn TabHolder::OnTabClick(EventParams &e) { // We have e.b set when it was an explicit click action. // In that case, we make the view gone and then visible - this scrolls scrollviews to the top. diff --git a/ext/native/ui/viewgroup.h b/ext/native/ui/viewgroup.h index 687e0f70b8..8dcf49b575 100644 --- a/ext/native/ui/viewgroup.h +++ b/ext/native/ui/viewgroup.h @@ -321,14 +321,7 @@ public: return tabContents; } - void SetCurrentTab(int tab) { - if (tab != currentTab_) { - tabs_[currentTab_]->SetVisibility(V_GONE); - currentTab_ = tab; - tabs_[currentTab_]->SetVisibility(V_VISIBLE); - } - tabStrip_->SetSelection(tab); - } + void SetCurrentTab(int tab); int GetCurrentTab() const { return currentTab_; } std::string Describe() const override { return "TabHolder: " + View::Describe(); }