diff options
| author | 2015-02-18 22:18:47 -0800 | |
|---|---|---|
| committer | 2015-02-18 22:26:22 -0800 | |
| commit | 5efd149ad56efb2a00332af5a791b403e7f70273 (patch) | |
| tree | 90492d27a1c67a480f8675c269a63932cee28432 /src | |
| parent | Merge pull request #580 from lioncash/emplace (diff) | |
| download | yuzu-5efd149ad56efb2a00332af5a791b403e7f70273.tar.gz yuzu-5efd149ad56efb2a00332af5a791b403e7f70273.tar.xz yuzu-5efd149ad56efb2a00332af5a791b403e7f70273.zip | |
Remove the useless msg_handler compilation unit that was left over from Dolphin
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/common/chunk_file.h | 2 | ||||
| -rw-r--r-- | src/common/common.h | 1 | ||||
| -rw-r--r-- | src/common/mem_arena.cpp | 7 | ||||
| -rw-r--r-- | src/common/memory_util.cpp | 14 | ||||
| -rw-r--r-- | src/common/msg_handler.cpp | 107 | ||||
| -rw-r--r-- | src/common/msg_handler.h | 56 | ||||
| -rw-r--r-- | src/core/core_timing.cpp | 4 |
8 files changed, 13 insertions, 180 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 8c87deaa4..0a8ef6dab 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -16,7 +16,6 @@ set(SRCS | |||
| 16 | mem_arena.cpp | 16 | mem_arena.cpp |
| 17 | memory_util.cpp | 17 | memory_util.cpp |
| 18 | misc.cpp | 18 | misc.cpp |
| 19 | msg_handler.cpp | ||
| 20 | scm_rev.cpp | 19 | scm_rev.cpp |
| 21 | string_util.cpp | 20 | string_util.cpp |
| 22 | symbols.cpp | 21 | symbols.cpp |
| @@ -53,7 +52,6 @@ set(HEADERS | |||
| 53 | math_util.h | 52 | math_util.h |
| 54 | mem_arena.h | 53 | mem_arena.h |
| 55 | memory_util.h | 54 | memory_util.h |
| 56 | msg_handler.h | ||
| 57 | platform.h | 55 | platform.h |
| 58 | scm_rev.h | 56 | scm_rev.h |
| 59 | scope_exit.h | 57 | scope_exit.h |
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index dc27da088..3f97d56bf 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h | |||
| @@ -637,7 +637,7 @@ public: | |||
| 637 | Do(cookie); | 637 | Do(cookie); |
| 638 | if(mode == PointerWrap::MODE_READ && cookie != arbitraryNumber) | 638 | if(mode == PointerWrap::MODE_READ && cookie != arbitraryNumber) |
| 639 | { | 639 | { |
| 640 | PanicAlertT("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber); | 640 | LOG_ERROR(Common, "After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber); |
| 641 | SetError(ERROR_FAILURE); | 641 | SetError(ERROR_FAILURE); |
| 642 | } | 642 | } |
| 643 | } | 643 | } |
diff --git a/src/common/common.h b/src/common/common.h index ad2de6f2e..f5f2f8c34 100644 --- a/src/common/common.h +++ b/src/common/common.h | |||
| @@ -28,7 +28,6 @@ private: | |||
| 28 | #include "common/assert.h" | 28 | #include "common/assert.h" |
| 29 | #include "common/logging/log.h" | 29 | #include "common/logging/log.h" |
| 30 | #include "common/common_types.h" | 30 | #include "common/common_types.h" |
| 31 | #include "common/msg_handler.h" | ||
| 32 | #include "common/common_funcs.h" | 31 | #include "common/common_funcs.h" |
| 33 | #include "common/common_paths.h" | 32 | #include "common/common_paths.h" |
| 34 | #include "common/platform.h" | 33 | #include "common/platform.h" |
diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp index a20361d6f..cc31a88cc 100644 --- a/src/common/mem_arena.cpp +++ b/src/common/mem_arena.cpp | |||
| @@ -218,7 +218,7 @@ u8* MemArena::Find4GBBase() | |||
| 218 | void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE, | 218 | void* base = mmap(0, 0x10000000, PROT_READ | PROT_WRITE, |
| 219 | MAP_ANON | MAP_SHARED, -1, 0); | 219 | MAP_ANON | MAP_SHARED, -1, 0); |
| 220 | if (base == MAP_FAILED) { | 220 | if (base == MAP_FAILED) { |
| 221 | PanicAlert("Failed to map 256 MB of memory space: %s", strerror(errno)); | 221 | LOG_ERROR(Common_Memory, "Failed to map 256 MB of memory space: %s", strerror(errno)); |
| 222 | return 0; | 222 | return 0; |
| 223 | } | 223 | } |
| 224 | munmap(base, 0x10000000); | 224 | munmap(base, 0x10000000); |
| @@ -338,7 +338,7 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena | |||
| 338 | // address space. | 338 | // address space. |
| 339 | if (!Memory_TryBase(base, views, num_views, flags, arena)) | 339 | if (!Memory_TryBase(base, views, num_views, flags, arena)) |
| 340 | { | 340 | { |
| 341 | PanicAlert("MemoryMap_Setup: Failed finding a memory base."); | 341 | LOG_ERROR(Common_Memory, "MemoryMap_Setup: Failed finding a memory base."); |
| 342 | return 0; | 342 | return 0; |
| 343 | } | 343 | } |
| 344 | #elif defined(_WIN32) | 344 | #elif defined(_WIN32) |
| @@ -363,12 +363,11 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena | |||
| 363 | if (!Memory_TryBase(base, views, num_views, flags, arena)) | 363 | if (!Memory_TryBase(base, views, num_views, flags, arena)) |
| 364 | { | 364 | { |
| 365 | LOG_ERROR(Common_Memory, "MemoryMap_Setup: Failed finding a memory base."); | 365 | LOG_ERROR(Common_Memory, "MemoryMap_Setup: Failed finding a memory base."); |
| 366 | PanicAlert("MemoryMap_Setup: Failed finding a memory base."); | ||
| 367 | return 0; | 366 | return 0; |
| 368 | } | 367 | } |
| 369 | #endif | 368 | #endif |
| 370 | if (base_attempts) | 369 | if (base_attempts) |
| 371 | PanicAlert("No possible memory base pointer found!"); | 370 | LOG_ERROR(Common_Memory, "No possible memory base pointer found!"); |
| 372 | return base; | 371 | return base; |
| 373 | } | 372 | } |
| 374 | 373 | ||
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index 8f982da89..7e69d31cb 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp | |||
| @@ -56,7 +56,7 @@ void* AllocateExecutableMemory(size_t size, bool low) | |||
| 56 | { | 56 | { |
| 57 | ptr = nullptr; | 57 | ptr = nullptr; |
| 58 | #endif | 58 | #endif |
| 59 | PanicAlert("Failed to allocate executable memory"); | 59 | LOG_ERROR(Common_Memory, "Failed to allocate executable memory"); |
| 60 | } | 60 | } |
| 61 | #if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT) | 61 | #if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT) |
| 62 | else | 62 | else |
| @@ -72,7 +72,7 @@ void* AllocateExecutableMemory(size_t size, bool low) | |||
| 72 | 72 | ||
| 73 | #if defined(_M_X64) | 73 | #if defined(_M_X64) |
| 74 | if ((u64)ptr >= 0x80000000 && low == true) | 74 | if ((u64)ptr >= 0x80000000 && low == true) |
| 75 | PanicAlert("Executable memory ended up above 2GB!"); | 75 | LOG_ERROR(Common_Memory, "Executable memory ended up above 2GB!"); |
| 76 | #endif | 76 | #endif |
| 77 | 77 | ||
| 78 | return ptr; | 78 | return ptr; |
| @@ -94,7 +94,7 @@ void* AllocateMemoryPages(size_t size) | |||
| 94 | // (unsigned long)size); | 94 | // (unsigned long)size); |
| 95 | 95 | ||
| 96 | if (ptr == nullptr) | 96 | if (ptr == nullptr) |
| 97 | PanicAlert("Failed to allocate raw memory"); | 97 | LOG_ERROR(Common_Memory, "Failed to allocate raw memory"); |
| 98 | 98 | ||
| 99 | return ptr; | 99 | return ptr; |
| 100 | } | 100 | } |
| @@ -117,7 +117,7 @@ void* AllocateAlignedMemory(size_t size,size_t alignment) | |||
| 117 | // (unsigned long)size); | 117 | // (unsigned long)size); |
| 118 | 118 | ||
| 119 | if (ptr == nullptr) | 119 | if (ptr == nullptr) |
| 120 | PanicAlert("Failed to allocate aligned memory"); | 120 | LOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); |
| 121 | 121 | ||
| 122 | return ptr; | 122 | return ptr; |
| 123 | } | 123 | } |
| @@ -129,7 +129,7 @@ void FreeMemoryPages(void* ptr, size_t size) | |||
| 129 | #ifdef _WIN32 | 129 | #ifdef _WIN32 |
| 130 | 130 | ||
| 131 | if (!VirtualFree(ptr, 0, MEM_RELEASE)) | 131 | if (!VirtualFree(ptr, 0, MEM_RELEASE)) |
| 132 | PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg()); | 132 | LOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n%s", GetLastErrorMsg()); |
| 133 | ptr = nullptr; // Is this our responsibility? | 133 | ptr = nullptr; // Is this our responsibility? |
| 134 | 134 | ||
| 135 | #else | 135 | #else |
| @@ -155,7 +155,7 @@ void WriteProtectMemory(void* ptr, size_t size, bool allowExecute) | |||
| 155 | #ifdef _WIN32 | 155 | #ifdef _WIN32 |
| 156 | DWORD oldValue; | 156 | DWORD oldValue; |
| 157 | if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue)) | 157 | if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue)) |
| 158 | PanicAlert("WriteProtectMemory failed!\n%s", GetLastErrorMsg()); | 158 | LOG_ERROR(Common_Memory, "WriteProtectMemory failed!\n%s", GetLastErrorMsg()); |
| 159 | #else | 159 | #else |
| 160 | mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ); | 160 | mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ); |
| 161 | #endif | 161 | #endif |
| @@ -166,7 +166,7 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute) | |||
| 166 | #ifdef _WIN32 | 166 | #ifdef _WIN32 |
| 167 | DWORD oldValue; | 167 | DWORD oldValue; |
| 168 | if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue)) | 168 | if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue)) |
| 169 | PanicAlert("UnWriteProtectMemory failed!\n%s", GetLastErrorMsg()); | 169 | LOG_ERROR(Common_Memory, "UnWriteProtectMemory failed!\n%s", GetLastErrorMsg()); |
| 170 | #else | 170 | #else |
| 171 | mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ); | 171 | mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ); |
| 172 | #endif | 172 | #endif |
diff --git a/src/common/msg_handler.cpp b/src/common/msg_handler.cpp deleted file mode 100644 index 4a47b518e..000000000 --- a/src/common/msg_handler.cpp +++ /dev/null | |||
| @@ -1,107 +0,0 @@ | |||
| 1 | // Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstdio> | ||
| 6 | |||
| 7 | #include "common/common.h" // Local | ||
| 8 | #include "common/string_util.h" | ||
| 9 | |||
| 10 | bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style); | ||
| 11 | static MsgAlertHandler msg_handler = DefaultMsgHandler; | ||
| 12 | static bool AlertEnabled = true; | ||
| 13 | |||
| 14 | std::string DefaultStringTranslator(const char* text); | ||
| 15 | static StringTranslator str_translator = DefaultStringTranslator; | ||
| 16 | |||
| 17 | // Select which of these functions that are used for message boxes. If | ||
| 18 | // wxWidgets is enabled we will use wxMsgAlert() that is defined in Main.cpp | ||
| 19 | void RegisterMsgAlertHandler(MsgAlertHandler handler) | ||
| 20 | { | ||
| 21 | msg_handler = handler; | ||
| 22 | } | ||
| 23 | |||
| 24 | // Select translation function. For wxWidgets use wxStringTranslator in Main.cpp | ||
| 25 | void RegisterStringTranslator(StringTranslator translator) | ||
| 26 | { | ||
| 27 | str_translator = translator; | ||
| 28 | } | ||
| 29 | |||
| 30 | // enable/disable the alert handler | ||
| 31 | void SetEnableAlert(bool enable) | ||
| 32 | { | ||
| 33 | AlertEnabled = enable; | ||
| 34 | } | ||
| 35 | |||
| 36 | // This is the first stop for gui alerts where the log is updated and the | ||
| 37 | // correct window is shown | ||
| 38 | bool MsgAlert(bool yes_no, int Style, const char* format, ...) | ||
| 39 | { | ||
| 40 | // Read message and write it to the log | ||
| 41 | std::string caption; | ||
| 42 | char buffer[2048]; | ||
| 43 | |||
| 44 | static std::string info_caption; | ||
| 45 | static std::string warn_caption; | ||
| 46 | static std::string ques_caption; | ||
| 47 | static std::string crit_caption; | ||
| 48 | |||
| 49 | if (!info_caption.length()) | ||
| 50 | { | ||
| 51 | info_caption = str_translator(_trans("Information")); | ||
| 52 | ques_caption = str_translator(_trans("Question")); | ||
| 53 | warn_caption = str_translator(_trans("Warning")); | ||
| 54 | crit_caption = str_translator(_trans("Critical")); | ||
| 55 | } | ||
| 56 | |||
| 57 | switch(Style) | ||
| 58 | { | ||
| 59 | case INFORMATION: | ||
| 60 | caption = info_caption; | ||
| 61 | break; | ||
| 62 | case QUESTION: | ||
| 63 | caption = ques_caption; | ||
| 64 | break; | ||
| 65 | case WARNING: | ||
| 66 | caption = warn_caption; | ||
| 67 | break; | ||
| 68 | case CRITICAL: | ||
| 69 | caption = crit_caption; | ||
| 70 | break; | ||
| 71 | } | ||
| 72 | |||
| 73 | va_list args; | ||
| 74 | va_start(args, format); | ||
| 75 | Common::CharArrayFromFormatV(buffer, sizeof(buffer)-1, str_translator(format).c_str(), args); | ||
| 76 | va_end(args); | ||
| 77 | |||
| 78 | LOG_INFO(Common, "%s: %s", caption.c_str(), buffer); | ||
| 79 | |||
| 80 | // Don't ignore questions, especially AskYesNo, PanicYesNo could be ignored | ||
| 81 | if (msg_handler && (AlertEnabled || Style == QUESTION || Style == CRITICAL)) | ||
| 82 | return msg_handler(caption.c_str(), buffer, yes_no, Style); | ||
| 83 | |||
| 84 | return true; | ||
| 85 | } | ||
| 86 | |||
| 87 | // Default non library dependent panic alert | ||
| 88 | bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style) | ||
| 89 | { | ||
| 90 | //#ifdef _WIN32 | ||
| 91 | // int STYLE = MB_ICONINFORMATION; | ||
| 92 | // if (Style == QUESTION) STYLE = MB_ICONQUESTION; | ||
| 93 | // if (Style == WARNING) STYLE = MB_ICONWARNING; | ||
| 94 | // | ||
| 95 | // return IDYES == MessageBox(0, UTF8ToTStr(text).c_str(), UTF8ToTStr(caption).c_str(), STYLE | (yes_no ? MB_YESNO : MB_OK)); | ||
| 96 | //#else | ||
| 97 | printf("%s\n", text); | ||
| 98 | return true; | ||
| 99 | //#endif | ||
| 100 | } | ||
| 101 | |||
| 102 | // Default (non) translator | ||
| 103 | std::string DefaultStringTranslator(const char* text) | ||
| 104 | { | ||
| 105 | return text; | ||
| 106 | } | ||
| 107 | |||
diff --git a/src/common/msg_handler.h b/src/common/msg_handler.h deleted file mode 100644 index 421f93e23..000000000 --- a/src/common/msg_handler.h +++ /dev/null | |||
| @@ -1,56 +0,0 @@ | |||
| 1 | // Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <string> | ||
| 8 | |||
| 9 | // Message alerts | ||
| 10 | enum MSG_TYPE | ||
| 11 | { | ||
| 12 | INFORMATION, | ||
| 13 | QUESTION, | ||
| 14 | WARNING, | ||
| 15 | CRITICAL | ||
| 16 | }; | ||
| 17 | |||
| 18 | typedef bool (*MsgAlertHandler)(const char* caption, const char* text, | ||
| 19 | bool yes_no, int Style); | ||
| 20 | typedef std::string (*StringTranslator)(const char* text); | ||
| 21 | |||
| 22 | void RegisterMsgAlertHandler(MsgAlertHandler handler); | ||
| 23 | void RegisterStringTranslator(StringTranslator translator); | ||
| 24 | |||
| 25 | extern bool MsgAlert(bool yes_no, int Style, const char* format, ...) | ||
| 26 | #ifdef __GNUC__ | ||
| 27 | __attribute__((format(printf, 3, 4))) | ||
| 28 | #endif | ||
| 29 | ; | ||
| 30 | void SetEnableAlert(bool enable); | ||
| 31 | |||
| 32 | #ifdef _MSC_VER | ||
| 33 | #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__) | ||
| 34 | #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__) | ||
| 35 | #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__) | ||
| 36 | #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__) | ||
| 37 | #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__) | ||
| 38 | // Use these macros (that do the same thing) if the message should be translated. | ||
| 39 | #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__) | ||
| 40 | #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__) | ||
| 41 | #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__) | ||
| 42 | #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__) | ||
| 43 | #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__) | ||
| 44 | #else | ||
| 45 | #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__) | ||
| 46 | #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__) | ||
| 47 | #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__) | ||
| 48 | #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__) | ||
| 49 | #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__) | ||
| 50 | // Use these macros (that do the same thing) if the message should be translated. | ||
| 51 | #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__) | ||
| 52 | #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__) | ||
| 53 | #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__) | ||
| 54 | #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__) | ||
| 55 | #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__) | ||
| 56 | #endif | ||
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index cabe2a074..6f716b1ca 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp | |||
| @@ -147,7 +147,7 @@ void RestoreRegisterEvent(int event_type, const char* name, TimedCallback callba | |||
| 147 | 147 | ||
| 148 | void UnregisterAllEvents() { | 148 | void UnregisterAllEvents() { |
| 149 | if (first) | 149 | if (first) |
| 150 | PanicAlert("Cannot unregister events with events pending"); | 150 | LOG_ERROR(Core_Timing, "Cannot unregister events with events pending"); |
| 151 | event_types.clear(); | 151 | event_types.clear(); |
| 152 | } | 152 | } |
| 153 | 153 | ||
| @@ -535,7 +535,7 @@ std::string GetScheduledEventsSummary() { | |||
| 535 | while (event) { | 535 | while (event) { |
| 536 | unsigned int t = event->type; | 536 | unsigned int t = event->type; |
| 537 | if (t >= event_types.size()) | 537 | if (t >= event_types.size()) |
| 538 | PanicAlert("Invalid event type"); // %i", t); | 538 | LOG_ERROR(Core_Timing, "Invalid event type"); // %i", t); |
| 539 | const char* name = event_types[event->type].name; | 539 | const char* name = event_types[event->type].name; |
| 540 | if (!name) | 540 | if (!name) |
| 541 | name = "[unknown]"; | 541 | name = "[unknown]"; |