mirror of
https://github.com/hyprwm/Hyprland.git
synced 2024-11-27 18:24:01 +03:00
simplify formats
This commit is contained in:
parent
db899e00e7
commit
b0d91cbf3a
@ -890,6 +890,34 @@ void CCompositor::cleanupFadingOut(const int& monid) {
|
||||
}
|
||||
|
||||
for (auto& ls : m_vSurfacesFadingOut) {
|
||||
|
||||
// sometimes somehow fucking happens wtf
|
||||
bool exists = false;
|
||||
for (auto& m : m_vMonitors) {
|
||||
for (auto& lsl : m->m_aLayerSurfaceLists) {
|
||||
for (auto& lsp : lsl) {
|
||||
if (lsp.get() == ls) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (exists)
|
||||
break;
|
||||
}
|
||||
|
||||
if (exists)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!exists) {
|
||||
m_vSurfacesFadingOut.erase(std::remove(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), ls));
|
||||
|
||||
Debug::log(LOG, "Fading out a non-existent LS??");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ls->monitorID != monid)
|
||||
continue;
|
||||
|
||||
|
@ -58,37 +58,20 @@ void Debug::log(LogLevel level, const char* fmt, ...) {
|
||||
ofs << "] ";
|
||||
}
|
||||
|
||||
char buf[LOGMESSAGESIZE] = "";
|
||||
char* outputStr;
|
||||
int logLen;
|
||||
char* outputStr = nullptr;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
logLen = vsnprintf(buf, sizeof buf, fmt, args);
|
||||
vasprintf(&outputStr, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if ((long unsigned int)logLen < sizeof buf) {
|
||||
outputStr = strdup(buf);
|
||||
} else {
|
||||
outputStr = (char*)malloc(logLen + 1);
|
||||
std::string output = std::string(outputStr);
|
||||
free(outputStr);
|
||||
|
||||
if (!outputStr) {
|
||||
printf("CRITICAL: Cannot alloc size %d for log! (Out of memory?)", logLen + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(outputStr, logLen + 1U, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
ofs << outputStr << "\n";
|
||||
ofs << output << "\n";
|
||||
|
||||
ofs.close();
|
||||
|
||||
// log it to the stdout too.
|
||||
std::cout << outputStr << "\n";
|
||||
|
||||
// free the log
|
||||
free(outputStr);
|
||||
std::cout << output << "\n";
|
||||
}
|
||||
|
@ -83,32 +83,14 @@ void wlr_signal_emit_safe(struct wl_signal *signal, void *data) {
|
||||
}
|
||||
|
||||
std::string getFormat(const char *fmt, ...) {
|
||||
char buf[LOGMESSAGESIZE] = "";
|
||||
char* outputStr;
|
||||
int logLen;
|
||||
char* outputStr = nullptr;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
logLen = vsnprintf(buf, sizeof buf, fmt, args);
|
||||
vasprintf(&outputStr, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if ((long unsigned int)logLen < sizeof buf) {
|
||||
outputStr = strdup(buf);
|
||||
} else {
|
||||
outputStr = (char*)malloc(logLen + 1);
|
||||
|
||||
if (!outputStr) {
|
||||
printf("CRITICAL: Cannot alloc size %d for log! (Out of memory?)", logLen + 1);
|
||||
return "";
|
||||
}
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(outputStr, logLen + 1U, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
std::string output = std::string(outputStr);
|
||||
|
||||
free(outputStr);
|
||||
|
||||
return output;
|
||||
|
Loading…
Reference in New Issue
Block a user