Fix the command line options when another instance is running
This commit is contained in:
parent
c5ff9edc40
commit
f5cd85c6de
|
@ -301,11 +301,11 @@ QByteArray CommandlineOptions::Serialize() const {
|
|||
s << *this;
|
||||
buf.close();
|
||||
|
||||
return buf.data();
|
||||
return buf.data().toBase64();
|
||||
}
|
||||
|
||||
void CommandlineOptions::Load(const QByteArray& serialized) {
|
||||
QByteArray copy(serialized);
|
||||
QByteArray copy = QByteArray::fromBase64(serialized);
|
||||
QBuffer buf(©);
|
||||
buf.open(QIODevice::ReadOnly);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class CommandlineOptions {
|
|||
friend QDataStream& operator>>(QDataStream& s, CommandlineOptions& a);
|
||||
|
||||
public:
|
||||
explicit CommandlineOptions(int argc = 0, char* *argv = nullptr);
|
||||
explicit CommandlineOptions(int argc = 0, char** argv = nullptr);
|
||||
|
||||
static const char* kHelpText;
|
||||
static const char* kVersionText;
|
||||
|
|
|
@ -111,7 +111,6 @@ namespace {
|
|||
|
||||
void LoadTranslation(const QString& prefix, const QString& path,
|
||||
const QString& language) {
|
||||
|
||||
QTranslator* t = new PoTranslator;
|
||||
if (t->load(prefix + "_" + language, path))
|
||||
QCoreApplication::installTranslator(t);
|
||||
|
@ -349,7 +348,8 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
a.setQuitOnLastWindowClosed(false);
|
||||
// Do this check again because another instance might have started by now
|
||||
if (a.isRunning() && a.sendMessage(options.Serialize(), 5000)) {
|
||||
if (a.isRunning() &&
|
||||
a.sendMessage(QString::fromLatin1(options.Serialize()), 5000)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -390,8 +390,8 @@ int main(int argc, char* argv[]) {
|
|||
// Add root CA cert for SoundCloud, whose certificate is missing on OS X.
|
||||
QSslSocket::addDefaultCaCertificates(
|
||||
QSslCertificate::fromPath(":/soundcloud-ca.pem", QSsl::Pem));
|
||||
QSslSocket::addDefaultCaCertificates(
|
||||
QSslCertificate::fromPath(":/Equifax_Secure_Certificate_Authority.pem", QSsl::Pem));
|
||||
QSslSocket::addDefaultCaCertificates(QSslCertificate::fromPath(
|
||||
":/Equifax_Secure_Certificate_Authority.pem", QSsl::Pem));
|
||||
|
||||
// Has the user forced a different language?
|
||||
QString override_language = options.language();
|
||||
|
|
|
@ -2045,15 +2045,9 @@ void MainWindow::PlaylistEditFinished(const QModelIndex& index) {
|
|||
if (index == playlist_menu_index_) SelectionSetValue();
|
||||
}
|
||||
|
||||
void MainWindow::CommandlineOptionsReceived(
|
||||
const QString& serialized_options) {
|
||||
if (serialized_options == "wake up!") {
|
||||
// Old versions of Clementine sent this - just ignore it
|
||||
return;
|
||||
}
|
||||
|
||||
void MainWindow::CommandlineOptionsReceived(const QString& string_options) {
|
||||
CommandlineOptions options;
|
||||
options.Load(serialized_options.toLatin1());
|
||||
options.Load(string_options.toLatin1());
|
||||
|
||||
if (options.is_empty()) {
|
||||
show();
|
||||
|
|
|
@ -240,7 +240,7 @@ signals:
|
|||
void AddCDTracks();
|
||||
void AddPodcast();
|
||||
|
||||
void CommandlineOptionsReceived(const QString &serialized_options);
|
||||
void CommandlineOptionsReceived(const QString& string_options);
|
||||
|
||||
void CheckForUpdates();
|
||||
|
||||
|
|
Loading…
Reference in New Issue