Fix UpdaterService class redefinition conflict

The MOC compiler was encountering two different definitions of UpdaterService:
1. A stub class in updater_dialog.h for non-Windows platforms
2. The real QObject-derived class in updater_service.h

Fixed by:
- Making updater_service.h include conditional in main.cpp (#ifdef _WIN32)
- Wrapping all UpdaterService usage in main.cpp with #ifdef _WIN32 blocks
- Adding clarifying comment to stub class in updater_dialog.h

This resolves the MOC compilation errors and ensures the updater
functionality is only available on Windows as intended.
This commit is contained in:
Zephyron
2025-09-21 15:49:19 +10:00
parent bc1b49285a
commit cefb781184
2 changed files with 6 additions and 1 deletions

View File

@@ -166,8 +166,8 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
#include "citron/uisettings.h"
#ifdef _WIN32
#include "citron/updater/updater_dialog.h"
#endif
#include "citron/updater/updater_service.h"
#endif
#include "citron/util/clickable_label.h"
#include "citron/util/performance_overlay.h"
#include "citron/util/vram_overlay.h"
@@ -5522,6 +5522,7 @@ int main(int argc, char* argv[]) {
QApplication app(argc, argv);
#ifdef _WIN32
// Check for and apply staged updates before starting the main application
std::filesystem::path app_dir = std::filesystem::path(QCoreApplication::applicationDirPath().toStdString());
if (Updater::UpdaterService::HasStagedUpdate(app_dir)) {
@@ -5531,6 +5532,7 @@ int main(int argc, char* argv[]) {
QObject::tr("Citron has been updated successfully!"));
}
}
#endif
#ifdef _WIN32
OverrideWindowsFont();
@@ -5581,6 +5583,7 @@ void GMainWindow::OnCheckForUpdates() {
}
void GMainWindow::CheckForUpdatesAutomatically() {
#ifdef _WIN32
// Check if automatic updates are enabled
if (!Settings::values.enable_auto_update_check.GetValue()) {
return;
@@ -5620,6 +5623,7 @@ void GMainWindow::CheckForUpdatesAutomatically() {
// Start the silent update check
updater_service->CheckForUpdates(update_url);
#endif
}
void GMainWindow::OnToggleGridView() {

View File

@@ -18,6 +18,7 @@
// Forward declarations for non-Windows platforms
namespace Updater {
struct UpdateInfo;
// Stub class for non-Windows platforms - not a QObject
class UpdaterService {
public:
enum class UpdateResult {