Hi,

I'd like to get https://codereview.qt-project.org/#change,22151,patchset=5 into 
5.0/api_changes branch. It's one more change to the logging framework, 
specifically to the signature of QMessageHandler (new in 5.0, old QtMsgHandler 
is unchanged):

void (*QMessageHandler)(QtMsgType, const QMessageLogContext &, const char *);

becomes

void (*QMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &);


The reason is to avoid unnecessary string conversions, especially on Windows. 
E.g.

qDebug() << "Hello World";

will right now result in

const char * -> QString conversion in QDebug::operator(const char *) 
(QString::fromAscii(), shouldn't this be QString::fromLatin1() btw?)
QString -> const char * conversion in QDebug::~QDebug() (QString::toLocal8Bit())
const char *-> QByteArray conversion in qMessageFormatString() for the default 
message handler
a QByteArray -> QString conversion in qWinMessageHandler() 
(QString::fromLocal8Bit)

So we're converting from latin1 to utf16 to local8bit to utf16 :) The patch 
mitigates this somewhat by passing const QString & as argument to the message 
handler, instead of const char *.

Note that QtDeclarative right now installs a message handler with the const 
char * signature. That means if the patch is accepted, we'd need to synchronize 
the qtbase with a qtdeclarative update.

Regards

Kai

PS: Robin Burchell originally pointed out the problem

--
Kai Koehne
Senior Software Engineer
Nokia, Mobile Phones
 
Nokia gate5 GmbH
Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany
Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443 B
Umsatzsteueridentifikationsnummer: DE 812 845 193
Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori

_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to