Compare commits
2 Commits
56e665301f
...
12e5623fe6
Author | SHA1 | Date | |
---|---|---|---|
12e5623fe6 | |||
cfdfb0a8c9 |
31
deps/ox/src/ox/logconn/logconn.cpp
vendored
31
deps/ox/src/ox/logconn/logconn.cpp
vendored
@@ -91,23 +91,28 @@ ox::Error LoggerConn::sendInit(const InitTraceMsg &msg) noexcept {
|
||||
}
|
||||
|
||||
void LoggerConn::msgSend() noexcept {
|
||||
while (true) {
|
||||
std::unique_lock lk(m_waitMut);
|
||||
m_waitCond.wait(lk);
|
||||
if (!m_running) {
|
||||
break;
|
||||
}
|
||||
std::lock_guard const buffLk(m_buffMut);
|
||||
try {
|
||||
while (true) {
|
||||
Array<char, units::KB> tmp;
|
||||
const auto read = m_buff.read(tmp.data(), tmp.size());
|
||||
if (!read) {
|
||||
std::unique_lock lk(m_waitMut);
|
||||
m_waitCond.wait(lk);
|
||||
if (!m_running) {
|
||||
break;
|
||||
}
|
||||
oxAssert(read <= tmp.size(), "logger trying to read too much data");
|
||||
//std::printf("LoggerConn: sending %lu bytes\n", read);
|
||||
std::ignore = send(tmp.data(), read);
|
||||
std::lock_guard const buffLk(m_buffMut);
|
||||
while (true) {
|
||||
Array<char, units::KB> tmp;
|
||||
const auto read = m_buff.read(tmp.data(), tmp.size());
|
||||
if (!read) {
|
||||
break;
|
||||
}
|
||||
oxAssert(read <= tmp.size(), "logger trying to read too much data");
|
||||
//std::printf("LoggerConn: sending %lu bytes\n", read);
|
||||
std::ignore = send(tmp.data(), read);
|
||||
}
|
||||
}
|
||||
} catch (std::exception const &e) {
|
||||
oxErrf("Exception in logger thread: {}\n", e.what());
|
||||
oxAssert(false, "logger thread exception");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -551,24 +551,36 @@ ox::Error StudioUI::handleMoveFile(ox::StringViewCR oldPath, ox::StringViewCR ne
|
||||
|
||||
ox::Error StudioUI::handleDeleteDir(ox::StringViewCR path) noexcept {
|
||||
auto const p = sfmt("{}/", path);
|
||||
for (auto &e : m_editors) {
|
||||
if (beginsWith(e->itemPath(), p)) {
|
||||
oxLogError(closeFile(path));
|
||||
m_closeActiveTab = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::ignore = m_editors.erase(
|
||||
std::remove_if(
|
||||
m_editors.begin(), m_editors.end(),
|
||||
[&](ox::UPtr<BaseEditor> const &e) {
|
||||
if (beginsWith(e->itemPath(), p)) {
|
||||
oxLogError(closeFile(path));
|
||||
if (e.get() != m_activeEditor) {
|
||||
return true;
|
||||
}
|
||||
m_closeActiveTab = true;
|
||||
}
|
||||
return false;
|
||||
}));
|
||||
return m_projectExplorer.refreshProjectTreeModel();
|
||||
}
|
||||
|
||||
ox::Error StudioUI::handleDeleteFile(ox::StringViewCR path) noexcept {
|
||||
for (auto &e : m_editors) {
|
||||
if (path == e->itemPath()) {
|
||||
oxLogError(closeFile(path));
|
||||
m_closeActiveTab = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::ignore = m_editors.erase(
|
||||
std::remove_if(
|
||||
m_editors.begin(), m_editors.end(),
|
||||
[&](ox::UPtr<BaseEditor> const &e) {
|
||||
if (path == e->itemPath()) {
|
||||
oxLogError(closeFile(path));
|
||||
if (e.get() != m_activeEditor) {
|
||||
return true;
|
||||
}
|
||||
m_closeActiveTab = true;
|
||||
}
|
||||
return false;
|
||||
}));
|
||||
return m_projectExplorer.refreshProjectTreeModel();
|
||||
}
|
||||
|
||||
@@ -666,10 +678,10 @@ ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool const makeActi
|
||||
}
|
||||
OX_REQUIRE(ext, fileExt(path));
|
||||
// create Editor
|
||||
BaseEditor *editor = nullptr;
|
||||
ox::UPtr<BaseEditor> editor;
|
||||
auto const err = m_editorMakers.contains(ext) ?
|
||||
m_editorMakers[ext](path).moveTo(editor) :
|
||||
ox::makeCatch<ClawEditor>(m_sctx, path).moveTo(editor);
|
||||
m_editorMakers[ext](path).to<ox::UPtr<BaseEditor>>().moveTo(editor) :
|
||||
ox::make_unique_catch<ClawEditor>(m_sctx, path).moveTo(editor);
|
||||
if (err) {
|
||||
if constexpr(!ox::defines::Debug) {
|
||||
oxErrf("Could not open Editor: {}\n", toStr(err));
|
||||
@@ -679,11 +691,11 @@ ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool const makeActi
|
||||
return err;
|
||||
}
|
||||
editor->closed.connect(this, &StudioUI::closeFile);
|
||||
m_editors.emplace_back(editor);
|
||||
auto const &e = m_editors.emplace_back(std::move(editor));
|
||||
m_openFiles.emplace_back(path);
|
||||
if (makeActiveTab) {
|
||||
m_activeEditor = m_editors.back().value->get();
|
||||
m_activeEditorUpdatePending = editor;
|
||||
m_activeEditorUpdatePending = e.get();
|
||||
}
|
||||
// save to config
|
||||
studio::editConfig<StudioConfig>(keelCtx(m_tctx), [&path](StudioConfig &config) {
|
||||
|
Reference in New Issue
Block a user