It's necessary to add a QCoreApplication to kdeinit4

潘卫平 wppan at redflag-linux.com
Tue Oct 14 03:03:16 BST 2008


Hi all,
I made two experiments:
the first program is:
#include <QCoreApplication>
#include <QFile>
#include <stdio.h>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
printf("%s\n", QFile::encodeName(QString::fromUtf8("/home/潘")).data());
return 0;
}
the output is:
/home/潘

the second program is:
#include <QCoreApplication>
#include <QFile>
#include <stdio.h>
int main(int argc, char *argv[])
{
//QCoreApplication app(argc, argv);
printf("%s\n", QFile::encodeName(QString::fromUtf8("/home/潘")).data());
return 0;
}
the output is:
/home/

QFile::encodeName got wrong file name without a QCoreApplication object !
(my locale is zh_CN.UTF-8)

>From the error messages:
"
trying to create local folder /home/.kde: Permission denied
trying to create local folder /home/.kde: Permission denied
Link points to "/tmp/ksocket-潘"
trying to create local folder /home/.kde: Permission denied
kdeinit4: Aborting. bind() failed: : No such file or directory
Could not bind to socket
'/home/.kde/socket-localhost.localdomain/kdeinit4__0'
"
I find that maybe something is wrong when binding a socket.

kdelibs/kinit/kinit.cpp
main() function calls kdeinit_library_path() function.
1808 kdeinit_library_path();

and in kdeinit_library_path() function,
1562 QByteArray socketName =
QFile::encodeName(KStandardDirs::locateLocal("socket",
QString("kdeinit4_%1").a rg(QLatin1String(display)), *s_instance));

I think that's the reason why kdeinit4 binds the socket wrongly,
and we should add a QCoreAoolication to make QFile, QDir and other QT
class work in kdeinit4.

Best regards!

pwp




More information about the kde-core-devel mailing list