Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,13 @@ endif ()
set (MSCORE_APPEND_SRC)

if (OS_IS_WIN)
list(APPEND MSCORE_APPEND_SRC ${WINDOWS_ICONS_RC})
set(MANIFEST_FILE_NAME "${EXECUTABLE_NAME}.manifest")
configure_file("configs/app_win.manifest.in" ${MANIFEST_FILE_NAME} @ONLY)

list(APPEND MSCORE_APPEND_SRC
${WINDOWS_ICONS_RC}
"${CMAKE_CURRENT_BINARY_DIR}/${MANIFEST_FILE_NAME}"
)
endif()

if (MUE_CONFIGURATION_IS_APPWEB)
Expand Down
41 changes: 41 additions & 0 deletions src/app/configs/app_win.manifest.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please move this file to app/configs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity type="win32" name="Muse.MuseScore.@MUSE_APP_NAME_MACHINE_READABLE@"
version="@[email protected]" />

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 and Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>

<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<dpiAwareness>PerMonitorV2</dpiAwareness>
<activeCodePage xmlns="http://schemas.microsoft.com/SMI/2019/WindowsSettings">UTF-8</activeCodePage>
</asmv3:windowsSettings>
</asmv3:application>

<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls"
version="6.0.0.0" processorArchitecture="*"
publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>

<!--
UAC settings:
- app should run at same integrity level as calling process
- app does not need to manipulate windows belonging to higher-integrity-level processes
-->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
57 changes: 4 additions & 53 deletions src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <csignal>

#include <QTextCodec>
#include <QApplication>
#include <QStyleHints>
#include <QQuickWindow>
Expand All @@ -36,13 +35,6 @@

#include "log.h"

#if (defined (_MSCVER) || defined (_MSC_VER))
#include <vector>
#include <algorithm>
#include <windows.h>
#include <shellapi.h>
#endif

#ifndef MUSE_MODULE_DIAGNOSTICS_CRASHPAD_CLIENT
static void crashCallback(int signum)
{
Expand Down Expand Up @@ -85,10 +77,6 @@ int main(int argc, char** argv)
// Setup global Qt application variables
// ====================================================

// Force the 8-bit text encoding to UTF-8. This is the default encoding on all supported platforms except for MSVC under Windows, which
// would otherwise default to the local ANSI code page and cause corruption of any non-ANSI Unicode characters in command-line arguments.
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));

app_init_qrc();

qputenv("QT_STYLE_OVERRIDE", "Fusion");
Expand Down Expand Up @@ -143,43 +131,6 @@ int main(int argc, char** argv)
QGuiApplication::setDesktopFileName("org.musescore.MuseScore" MUSE_APP_INSTALL_SUFFIX);
#endif

#if (defined (_MSCVER) || defined (_MSC_VER))
// // On MSVC under Windows, we need to manually retrieve the command-line arguments and convert them from UTF-16 to UTF-8.
// // This prevents data loss if there are any characters that wouldn't fit in the local ANSI code page.

auto utf8_encode = [](const wchar_t* wstr) -> std::string
{
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], -1, 0, 0, 0, 0);
std::string strTo(size_needed, 0);
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], -1, &strTo[0], size_needed, 0, 0);
return strTo;
};

int argc_utf16 = 0;
wchar_t** argv_utf16 = CommandLineToArgvW(GetCommandLineW(), &argc_utf16);
std::vector<std::string> argsUtf8; // store data
for (int i = 0; i < argc_utf16; ++i) {
argsUtf8.push_back(utf8_encode(argv_utf16[i]));
}

std::vector<char*> argsUtf8_с; // convert to char*
for (std::string& arg : argsUtf8) {
argsUtf8_с.push_back(arg.data());
}

// Don't use the arguments passed to main(), because they're in the local ANSI code page.
Q_UNUSED(argc);
Q_UNUSED(argv);

int argcFinal = argc_utf16;
char** argvFinal = argsUtf8_с.data();
#else

int argcFinal = argc;
char** argvFinal = argv;

#endif

using namespace muse;
using namespace mu::app;

Expand All @@ -189,22 +140,22 @@ int main(int argc, char** argv)
#ifdef MUE_ENABLE_CONSOLEAPP
CommandLineParser commandLineParser;
commandLineParser.init();
commandLineParser.parse(argcFinal, argvFinal);
commandLineParser.parse(argc, argv);

IApplication::RunMode runMode = commandLineParser.runMode();
QCoreApplication* qapp = nullptr;

if (runMode == IApplication::RunMode::AudioPluginRegistration) {
qapp = new QCoreApplication(argcFinal, argvFinal);
qapp = new QCoreApplication(argc, argv);
} else {
qapp = new QApplication(argcFinal, argvFinal);
qapp = new QApplication(argc, argv);
}

commandLineParser.processBuiltinArgs(*qapp);
CmdOptions opt = commandLineParser.options();

#else
QCoreApplication* qapp = new QApplication(argcFinal, argvFinal);
QCoreApplication* qapp = new QApplication(argc, argv);
CmdOptions opt;
opt.runMode = IApplication::RunMode::GuiApp;
#endif
Expand Down
Loading