fix: single app does not works under windows
This commit is contained in:
parent
14d20fd925
commit
98d352a7c1
|
@ -13,7 +13,7 @@ set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Widgets Multimedia REQUIRED)
|
find_package(Qt5 COMPONENTS Widgets Multimedia Network REQUIRED)
|
||||||
|
|
||||||
set (EXE_NAME pmusic)
|
set (EXE_NAME pmusic)
|
||||||
|
|
||||||
|
@ -35,7 +35,15 @@ add_executable(${EXE_NAME}
|
||||||
ID3v2Pic.h
|
ID3v2Pic.h
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(${EXE_NAME} PRIVATE Qt5::Widgets Qt5::Multimedia)
|
target_link_libraries(${EXE_NAME} PRIVATE Qt5::Widgets Qt5::Multimedia Qt5::Network)
|
||||||
|
|
||||||
|
# Extra build settings
|
||||||
|
if (WIN32)
|
||||||
|
set_property (
|
||||||
|
TARGET ${EXE_NAME}
|
||||||
|
PROPERTY WIN32_EXECUTABLE true
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Helper macros for install settings
|
# Helper macros for install settings
|
||||||
macro (pmusic_convert_to_relative_path _var)
|
macro (pmusic_convert_to_relative_path _var)
|
||||||
|
|
|
@ -16,6 +16,7 @@ void SingleApplicationManager::on_localSocket_newConnection()
|
||||||
QScopedPointer<QLocalSocket> socket(m_localServer->nextPendingConnection());
|
QScopedPointer<QLocalSocket> socket(m_localServer->nextPendingConnection());
|
||||||
if (socket) {
|
if (socket) {
|
||||||
socket->waitForReadyRead(500);
|
socket->waitForReadyRead(500);
|
||||||
|
|
||||||
QDataStream dataStream(socket.data());
|
QDataStream dataStream(socket.data());
|
||||||
QVariant data;
|
QVariant data;
|
||||||
dataStream.startTransaction();
|
dataStream.startTransaction();
|
||||||
|
@ -44,11 +45,14 @@ bool SingleApplicationManager::checkSingleInstance(QVariant data)
|
||||||
QLocalSocket socket;
|
QLocalSocket socket;
|
||||||
socket.connectToServer(m_applicationKey);
|
socket.connectToServer(m_applicationKey);
|
||||||
if (socket.waitForConnected(500)) {
|
if (socket.waitForConnected(500)) {
|
||||||
QDataStream dataStream(&socket);
|
QByteArray block;
|
||||||
dataStream << data;
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
|
out << data;
|
||||||
|
|
||||||
|
socket.write(block);
|
||||||
socket.waitForBytesWritten();
|
socket.waitForBytesWritten();
|
||||||
socket.close();
|
socket.flush();
|
||||||
|
socket.disconnectFromServer();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user