Try parsing a message in main(), both in the main thread and in a QtConcurrent thread.

(cherry picked from commit 4446b277814ae4afe7d4aba85eb4fd5475843880)

Fixes issue 3265
This commit is contained in:
David Sansome 2012-11-11 19:54:43 +11:00
parent 7d65d425e0
commit 141bdc6888
1 changed files with 20 additions and 0 deletions

View File

@ -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 <QSqlQuery>
#include <QTextCodec>
#include <QTranslator>
#include <QtConcurrentRun>
#include <QtDebug>
#include <glib-object.h>
@ -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");