mirror of
https://github.com/johndoe6345789/tla_visualiser.git
synced 2026-04-24 13:45:03 +00:00
Clean up comments and improve cache directory fallback logic
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -55,8 +55,8 @@ Item {
|
||||
ctx.lineWidth = 2
|
||||
// Edge drawing would use model.getTransitions()
|
||||
|
||||
// Draw all nodes (no arbitrary limit)
|
||||
var maxNodesToShow = Math.min(nodeCount, 100) // Reasonable limit for performance
|
||||
// Draw nodes (limit to 100 for performance)
|
||||
var maxNodesToShow = Math.min(nodeCount, 100)
|
||||
for (var i = 0; i < maxNodesToShow; i++) {
|
||||
var angle = (i / nodeCount) * 2 * Math.PI
|
||||
var x = centerX + radius * Math.cos(angle)
|
||||
|
||||
@@ -23,19 +23,34 @@ public:
|
||||
Impl() {
|
||||
curl = curl_easy_init();
|
||||
// Create cache directory - prefer user-specific cache location
|
||||
// Fallback to a subdirectory in temp if user directories unavailable
|
||||
#ifdef _WIN32
|
||||
const char* appdata = std::getenv("APPDATA");
|
||||
if (appdata) {
|
||||
cache_dir = std::string(appdata) + "/tla_visualiser/cache";
|
||||
} else {
|
||||
cache_dir = std::filesystem::temp_directory_path() / "tla_visualiser_cache";
|
||||
// Windows fallback: use ProgramData or temp with warning
|
||||
const char* programdata = std::getenv("ProgramData");
|
||||
if (programdata) {
|
||||
cache_dir = std::string(programdata) + "/tla_visualiser/cache";
|
||||
} else {
|
||||
cache_dir = std::filesystem::temp_directory_path() / "tla_visualiser_cache";
|
||||
std::cerr << "Warning: Using temp directory for cache. Consider setting APPDATA." << std::endl;
|
||||
}
|
||||
}
|
||||
#else
|
||||
const char* home = std::getenv("HOME");
|
||||
if (home) {
|
||||
cache_dir = std::string(home) + "/.cache/tla_visualiser";
|
||||
} else {
|
||||
cache_dir = std::filesystem::temp_directory_path() / "tla_visualiser_cache";
|
||||
// Unix fallback: try XDG or temp with warning
|
||||
const char* xdg_cache = std::getenv("XDG_CACHE_HOME");
|
||||
if (xdg_cache) {
|
||||
cache_dir = std::string(xdg_cache) + "/tla_visualiser";
|
||||
} else {
|
||||
cache_dir = std::filesystem::temp_directory_path() / "tla_visualiser_cache";
|
||||
std::cerr << "Warning: Using temp directory for cache. Consider setting HOME or XDG_CACHE_HOME." << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
std::filesystem::create_directories(cache_dir);
|
||||
|
||||
@@ -94,7 +94,8 @@ void TraceViewerModel::loadTrace(const TLCRunner::CounterExample& trace,
|
||||
step.variables = it->variables;
|
||||
|
||||
// Find action (transition to this state)
|
||||
if (step_num > 0) { // Fixed: check before increment
|
||||
// Only non-initial steps have transitions
|
||||
if (step_num > 0) {
|
||||
auto trans_it = std::find_if(results.transitions.begin(), results.transitions.end(),
|
||||
[state_id](const TLCRunner::Transition& t) { return t.to_state == state_id; });
|
||||
if (trans_it != results.transitions.end()) {
|
||||
|
||||
Reference in New Issue
Block a user