From 141bdc688892603c865f516f061c3b0f670a5c7b Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sun, 11 Nov 2012 19:54:43 +1100 Subject: [PATCH] Try parsing a message in main(), both in the main thread and in a QtConcurrent thread. (cherry picked from commit 4446b277814ae4afe7d4aba85eb4fd5475843880) Fixes issue 3265 --- src/main.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index faf397d9f..b7ea7b1c5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,6 +50,8 @@ #include "version.h" #include "widgets/osd.h" +#include "tagreadermessages.pb.h" + #include "qtsingleapplication.h" #include "qtsinglecoreapplication.h" @@ -61,6 +63,7 @@ #include #include #include +#include #include #include @@ -225,6 +228,17 @@ void ScanGIOModulePath() { } #endif +void ParseAProto() { + const QByteArray data = QByteArray::fromHex( + "08001a8b010a8801b2014566696c653a2f2f2f453a2f4d7573696b2f28414c42554d2" + "9253230476f74616e25323050726f6a6563742532302d253230416d6269656e742532" + "304c6f756e67652e6d786dba012a28414c42554d2920476f74616e2050726f6a65637" + "4202d20416d6269656e74204c6f756e67652e6d786dc001c7a7efd104c801bad685e4" + "04d001eeca32"); + pb::tagreader::Message message; + message.ParseFromArray(data.constData(), data.size()); +} + int main(int argc, char *argv[]) { if (CrashReporting::SendCrashReport(argc, argv)) { return 0; @@ -391,6 +405,12 @@ int main(int argc, char *argv[]) { // Icons IconLoader::Init(); + // This is a nasty hack to ensure that everything in libprotobuf is + // initialised in the main thread. It fixes issue 3265 but nobody knows why. + // Don't remove this unless you can reproduce the error that it fixes. + ParseAProto(); + QtConcurrent::run(&ParseAProto); + Application app; Echonest::Config::instance()->setAPIKey("DFLFLJBUF4EGTXHIG");