commit cff44cd3cd810a6641c61cb751725dee536cf438
parent 063be45cf07e14e76fd9f24a4ddd887bfd973d68
Author: Andrew Laack <andrew@laack.co>
Date: Wed, 23 Sep 2026 17:10:54 -0500
Use thread to open browser bc they are terrible pieces of software.
Diffstat:
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/browser.hpp b/include/browser.hpp
@@ -20,6 +20,7 @@ class Browser {
std::vector<std::atomic<bool>> done;
std::unordered_map<std::string, int> previousStatusCodes;
std::vector<Link*> siteHistory;
+ std::thread openThread;
int previousIdx = -1;
Cache* visitedCache;
Cache* preFetchCache;
diff --git a/src/browser.cpp b/src/browser.cpp
@@ -84,7 +84,14 @@ void Browser::goToSite(std::string url, bool addToHistory, bool refresh) {
std::string urlString = destination->getLinkDestination().to_string();
std::string scheme = destination->getLinkDestination().get_scheme();
if(scheme != "gemini" && scheme != "file" && scheme != "about") { // TODO: Should I use about or just a fs file?
- openUrl(urlString);
+ if(openThread.joinable()) {
+ openThread.join();
+ }
+
+ // this doesn't have to be blocking...
+ // my browser hangs very often so yea.
+ openThread = std::thread(openUrl, urlString);
+
delete destination;
return;
}
@@ -219,6 +226,10 @@ Browser::~Browser() {
}
}
+ if (openThread.joinable()) {
+ openThread.join();
+ }
+
delete visitedCache;
delete preFetchCache;
delete currentSite;