aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yml2
-rw-r--r--.github/workflows/winget.yml2
-rw-r--r--flake.lock31
-rw-r--r--flake.nix7
-rw-r--r--launcher/CMakeLists.txt4
-rw-r--r--launcher/minecraft/mod/ResourceFolderModel.cpp7
-rw-r--r--launcher/minecraft/mod/ResourceFolderModel.h2
-rw-r--r--launcher/net/NetJob.cpp4
-rw-r--r--launcher/tasks/ConcurrentTask.cpp36
-rw-r--r--launcher/tasks/ConcurrentTask.h9
-rw-r--r--launcher/tasks/MultipleOptionsTask.cpp4
-rw-r--r--launcher/tasks/SequentialTask.cpp4
-rw-r--r--nix/default.nix14
13 files changed, 68 insertions, 58 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 1ba5d0e4..f415741d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -165,7 +165,7 @@ jobs:
- name: Retrieve ccache cache (Windows MinGW-w64)
if: runner.os == 'Windows' && matrix.msystem != '' && inputs.build_type == 'Debug'
- uses: actions/cache@v3.0.11
+ uses: actions/cache@v3.2.1
with:
path: '${{ github.workspace }}\.ccache'
key: ${{ matrix.os }}-mingw-w64
diff --git a/.github/workflows/winget.yml b/.github/workflows/winget.yml
index b4136df5..ef9561cf 100644
--- a/.github/workflows/winget.yml
+++ b/.github/workflows/winget.yml
@@ -11,5 +11,5 @@ jobs:
with:
identifier: PrismLauncher.PrismLauncher
version: ${{ github.event.release.tag_name }}
- installers-regex: 'PrismLauncher-Windows-MSVC(:?-arm64)?-Setup-.+\.exe$'
+ installers-regex: 'PrismLauncher-Windows-MSVC(:?-arm64|-Legacy)?-Setup-.+\.exe$'
token: ${{ secrets.WINGET_TOKEN }}
diff --git a/flake.lock b/flake.lock
index 7c0bb2f8..051e1664 100644
--- a/flake.lock
+++ b/flake.lock
@@ -3,11 +3,11 @@
"flake-compat": {
"flake": false,
"locked": {
- "lastModified": 1650374568,
- "narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
+ "lastModified": 1668681692,
+ "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=",
"owner": "edolstra",
"repo": "flake-compat",
- "rev": "b4a34015c698c7793d592d66adbab377907a2be8",
+ "rev": "009399224d5e398d03b22badca40a37ac85412a1",
"type": "github"
},
"original": {
@@ -34,11 +34,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1666057921,
- "narHash": "sha256-VpQqtXdj6G7cH//SvoprjR7XT3KS7p+tCVebGK1N6tE=",
+ "lastModified": 1671417167,
+ "narHash": "sha256-JkHam6WQOwZN1t2C2sbp1TqMv3TVRjzrdoejqfefwrM=",
"owner": "nixos",
"repo": "nixpkgs",
- "rev": "88eab1e431cabd0ed621428d8b40d425a07af39f",
+ "rev": "bb31220cca6d044baa6dc2715b07497a2a7c4bc7",
"type": "github"
},
"original": {
@@ -52,24 +52,7 @@
"inputs": {
"flake-compat": "flake-compat",
"libnbtplusplus": "libnbtplusplus",
- "nixpkgs": "nixpkgs",
- "tomlplusplus": "tomlplusplus"
- }
- },
- "tomlplusplus": {
- "flake": false,
- "locked": {
- "lastModified": 1666091090,
- "narHash": "sha256-djpMCFPvkJcfynV8WnsYdtwLq+J7jpV1iM4C6TojiyM=",
- "owner": "marzer",
- "repo": "tomlplusplus",
- "rev": "1e4a3833d013aee08f58c5b31c69f709afc69f73",
- "type": "github"
- },
- "original": {
- "owner": "marzer",
- "repo": "tomlplusplus",
- "type": "github"
+ "nixpkgs": "nixpkgs"
}
}
},
diff --git a/flake.nix b/flake.nix
index b1e07c91..5615a758 100644
--- a/flake.nix
+++ b/flake.nix
@@ -5,10 +5,9 @@
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
libnbtplusplus = { url = "github:PrismLauncher/libnbtplusplus"; flake = false; };
- tomlplusplus = { url = "github:marzer/tomlplusplus"; flake = false; };
};
- outputs = { self, nixpkgs, libnbtplusplus, tomlplusplus, ... }:
+ outputs = { self, nixpkgs, libnbtplusplus, ... }:
let
# User-friendly version number.
version = builtins.substring 0 8 self.lastModifiedDate;
@@ -23,8 +22,8 @@
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
packagesFn = pkgs: rec {
- prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; };
- prismlauncher = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus tomlplusplus; };
+ prismlauncher-qt5 = pkgs.libsForQt5.callPackage ./nix { inherit version self libnbtplusplus; };
+ prismlauncher = pkgs.qt6Packages.callPackage ./nix { inherit version self libnbtplusplus; };
};
in
{
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 439feb44..a0d92b6e 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -1166,6 +1166,8 @@ if(INSTALL_BUNDLE STREQUAL "full")
CONFIGURATIONS Debug RelWithDebInfo ""
DESTINATION ${PLUGIN_DEST_DIR}
COMPONENT Runtime
+ PATTERN "*qopensslbackend*" EXCLUDE
+ PATTERN "*qcertonlybackend*" EXCLUDE
)
install(
DIRECTORY "${QT_PLUGINS_DIR}/tls"
@@ -1175,6 +1177,8 @@ if(INSTALL_BUNDLE STREQUAL "full")
REGEX "dd\\." EXCLUDE
REGEX "_debug\\." EXCLUDE
REGEX "\\.dSYM" EXCLUDE
+ PATTERN "*qopensslbackend*" EXCLUDE
+ PATTERN "*qcertonlybackend*" EXCLUDE
)
endif()
configure_file(
diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp
index 0310c8f6..a52c5db3 100644
--- a/launcher/minecraft/mod/ResourceFolderModel.cpp
+++ b/launcher/minecraft/mod/ResourceFolderModel.cpp
@@ -20,6 +20,7 @@ ResourceFolderModel::ResourceFolderModel(QDir dir, QObject* parent) : QAbstractL
m_dir.setSorting(QDir::Name | QDir::IgnoreCase | QDir::LocaleAware);
connect(&m_watcher, &QFileSystemWatcher::directoryChanged, this, &ResourceFolderModel::directoryChanged);
+ connect(&m_helper_thread_task, &ConcurrentTask::finished, this, [this]{ m_helper_thread_task.clear(); });
}
ResourceFolderModel::~ResourceFolderModel()
@@ -275,7 +276,11 @@ void ResourceFolderModel::resolveResource(Resource* res)
connect(
task, &Task::finished, this, [=] { m_active_parse_tasks.remove(ticket); }, Qt::ConnectionType::QueuedConnection);
- QThreadPool::globalInstance()->start(task);
+ m_helper_thread_task.addTask(task);
+
+ if (!m_helper_thread_task.isRunning()) {
+ QThreadPool::globalInstance()->start(&m_helper_thread_task);
+ }
}
void ResourceFolderModel::onUpdateSucceeded()
diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h
index fe283b04..f1bc2dd7 100644
--- a/launcher/minecraft/mod/ResourceFolderModel.h
+++ b/launcher/minecraft/mod/ResourceFolderModel.h
@@ -10,6 +10,7 @@
#include "Resource.h"
#include "tasks/Task.h"
+#include "tasks/ConcurrentTask.h"
class QSortFilterProxyModel;
@@ -197,6 +198,7 @@ class ResourceFolderModel : public QAbstractListModel {
// Represents the relationship between a resource's internal ID and it's row position on the model.
QMap<QString, int> m_resources_index;
+ ConcurrentTask m_helper_thread_task;
QMap<int, Task::Ptr> m_active_parse_tasks;
std::atomic<int> m_next_resolution_ticket = 0;
};
diff --git a/launcher/net/NetJob.cpp b/launcher/net/NetJob.cpp
index 8ced1b7e..9b5d4f1b 100644
--- a/launcher/net/NetJob.cpp
+++ b/launcher/net/NetJob.cpp
@@ -123,7 +123,7 @@ auto NetJob::getFailedFiles() -> QList<QString>
void NetJob::updateState()
{
- emit progress(m_done.count(), m_total_size);
+ emit progress(m_done.count(), totalSize());
setStatus(tr("Executing %1 task(s) (%2 out of %3 are done)")
- .arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(m_total_size)));
+ .arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(totalSize())));
}
diff --git a/launcher/tasks/ConcurrentTask.cpp b/launcher/tasks/ConcurrentTask.cpp
index ce08a6a2..a890013e 100644
--- a/launcher/tasks/ConcurrentTask.cpp
+++ b/launcher/tasks/ConcurrentTask.cpp
@@ -27,18 +27,13 @@ auto ConcurrentTask::getStepTotalProgress() const -> qint64
void ConcurrentTask::addTask(Task::Ptr task)
{
- if (!isRunning())
- m_queue.append(task);
- else
- qWarning() << "Tried to add a task to a running concurrent task!";
+ m_queue.append(task);
}
void ConcurrentTask::executeTask()
{
- m_total_size = m_queue.size();
-
// Start the least amount of tasks needed, but at least one
- int num_starts = std::max(1, std::min(m_total_max_size, m_total_size));
+ int num_starts = qMax(1, qMin(m_total_max_size, m_queue.size()));
for (int i = 0; i < num_starts; i++) {
QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
}
@@ -73,6 +68,20 @@ bool ConcurrentTask::abort()
return suceedeed;
}
+void ConcurrentTask::clear()
+{
+ Q_ASSERT(!isRunning());
+
+ m_done.clear();
+ m_failed.clear();
+ m_queue.clear();
+
+ m_aborted = false;
+
+ m_progress = 0;
+ m_stepProgress = 0;
+}
+
void ConcurrentTask::startNext()
{
if (m_aborted || m_doing.count() > m_total_max_size)
@@ -101,9 +110,14 @@ void ConcurrentTask::startNext()
setStepStatus(next->isMultiStep() ? next->getStepStatus() : next->getStatus());
updateState();
- QCoreApplication::processEvents();
+ QMetaObject::invokeMethod(next.get(), &Task::start, Qt::QueuedConnection);
- next->start();
+ // Allow going up the number of concurrent tasks in case of tasks being added in the middle of a running task.
+ int num_starts = m_total_max_size - m_doing.size();
+ for (int i = 0; i < num_starts; i++)
+ QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
+
+ QCoreApplication::processEvents();
}
void ConcurrentTask::subTaskSucceeded(Task::Ptr task)
@@ -145,7 +159,7 @@ void ConcurrentTask::subTaskProgress(qint64 current, qint64 total)
void ConcurrentTask::updateState()
{
- setProgress(m_done.count(), m_total_size);
+ setProgress(m_done.count(), totalSize());
setStatus(tr("Executing %1 task(s) (%2 out of %3 are done)")
- .arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(m_total_size)));
+ .arg(QString::number(m_doing.count()), QString::number(m_done.count()), QString::number(totalSize())));
}
diff --git a/launcher/tasks/ConcurrentTask.h b/launcher/tasks/ConcurrentTask.h
index f1279d32..b46919fb 100644
--- a/launcher/tasks/ConcurrentTask.h
+++ b/launcher/tasks/ConcurrentTask.h
@@ -24,6 +24,11 @@ public:
public slots:
bool abort() override;
+ /** Resets the internal state of the task.
+ * This allows the same task to be re-used.
+ */
+ void clear();
+
protected
slots:
void executeTask() override;
@@ -36,6 +41,9 @@ slots:
void subTaskProgress(qint64 current, qint64 total);
protected:
+ // NOTE: This is not thread-safe.
+ [[nodiscard]] unsigned int totalSize() const { return m_queue.size() + m_doing.size() + m_done.size(); }
+
void setStepStatus(QString status) { m_step_status = status; emit stepStatus(status); };
virtual void updateState();
@@ -51,7 +59,6 @@ protected:
QHash<Task*, Task::Ptr> m_failed;
int m_total_max_size;
- int m_total_size;
qint64 m_stepProgress = 0;
qint64 m_stepTotalProgress = 100;
diff --git a/launcher/tasks/MultipleOptionsTask.cpp b/launcher/tasks/MultipleOptionsTask.cpp
index 5ad6181f..034499df 100644
--- a/launcher/tasks/MultipleOptionsTask.cpp
+++ b/launcher/tasks/MultipleOptionsTask.cpp
@@ -22,6 +22,6 @@ void MultipleOptionsTask::startNext()
void MultipleOptionsTask::updateState()
{
- setProgress(m_done.count(), m_total_size);
- setStatus(tr("Attempting task %1 out of %2").arg(QString::number(m_doing.count() + m_done.count()), QString::number(m_total_size)));
+ setProgress(m_done.count(), totalSize());
+ setStatus(tr("Attempting task %1 out of %2").arg(QString::number(m_doing.count() + m_done.count()), QString::number(totalSize())));
}
diff --git a/launcher/tasks/SequentialTask.cpp b/launcher/tasks/SequentialTask.cpp
index a34137cb..b2f86328 100644
--- a/launcher/tasks/SequentialTask.cpp
+++ b/launcher/tasks/SequentialTask.cpp
@@ -17,6 +17,6 @@ void SequentialTask::startNext()
void SequentialTask::updateState()
{
- setProgress(m_done.count(), m_total_size);
- setStatus(tr("Executing task %1 out of %2").arg(QString::number(m_doing.count() + m_done.count()), QString::number(m_total_size)));
+ setProgress(m_done.count(), totalSize());
+ setStatus(tr("Executing task %1 out of %2").arg(QString::number(m_doing.count() + m_done.count()), QString::number(totalSize())));
}
diff --git a/nix/default.nix b/nix/default.nix
index 6050fd37..82ba9c7d 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -2,7 +2,7 @@
, stdenv
, cmake
, jdk8
-, jdk
+, jdk17
, zlib
, file
, wrapQtAppsHook
@@ -16,15 +16,15 @@
, glfw
, openal
, extra-cmake-modules
+, tomlplusplus
, ghc_filesystem
, msaClientID ? ""
-, jdks ? [ jdk jdk8 ]
+, jdks ? [ jdk17 jdk8 ]
# flake
, self
, version
, libnbtplusplus
-, tomlplusplus
}:
stdenv.mkDerivation rec {
@@ -33,13 +33,14 @@ stdenv.mkDerivation rec {
src = lib.cleanSource self;
- nativeBuildInputs = [ extra-cmake-modules cmake file jdk wrapQtAppsHook ];
+ nativeBuildInputs = [ extra-cmake-modules cmake file jdk17 wrapQtAppsHook ];
buildInputs = [
qtbase
qtsvg
zlib
quazip
ghc_filesystem
+ tomlplusplus
] ++ lib.optional (lib.versionAtLeast qtbase.version "6") qtwayland;
cmakeFlags = lib.optionals (msaClientID != "") [ "-DLauncher_MSA_CLIENT_ID=${msaClientID}" ]
@@ -52,11 +53,6 @@ stdenv.mkDerivation rec {
ln -s ${libnbtplusplus}/* source/libraries/libnbtplusplus
chmod -R +r+w source/libraries/libnbtplusplus
chown -R $USER: source/libraries/libnbtplusplus
- rm -rf source/libraries/tomlplusplus
- mkdir source/libraries/tomlplusplus
- ln -s ${tomlplusplus}/* source/libraries/tomlplusplus
- chmod -R +r+w source/libraries/tomlplusplus
- chown -R $USER: source/libraries/tomlplusplus
'';
postInstall =