[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: KDE/kdelibs/kdecore/kernel
From: Alexis_Ménard <menard () kde ! org>
Date: 2009-02-02 16:55:37
Message-ID: 81941aea0902020855r38ff9ffft97cbc8ad095b7e36 () mail ! gmail ! com
[Download RAW message or body]
On Mon, Feb 2, 2009 at 5:47 PM, Olivier Goffart <ogoffart@kde.org> wrote:
> SVN commit 920285 by ogoffart:
>
> Create a default KComponenentData if there is none.
> This is usefull for pure Qt applications that loads KDE plugins.
>
> KStyle and Oxygen actually worked around the problem but that can be
> removed
> QtCreator may crash when opening a file dialog because KFileDialog gets
> hooked by some designer plugin and, KFileDialog request KGlobal::config for
> many things.
>
> BUG: 182861
>
>
>
> M +21 -7 kglobal.cpp
>
>
> --- trunk/KDE/kdelibs/kdecore/kernel/kglobal.cpp #920284:920285
> @@ -1,6 +1,7 @@
> /* This file is part of the KDE libraries
> Copyright (C) 1999 Sirtaj Singh Kanq <taj@kde.org>
> Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
> + Copyright (C) 2009 Olivier Goffart <ogoffart@kde.org>
>
> This library is free software; you can redistribute it and/or
> modify it under the terms of the GNU Library General Public
> @@ -93,31 +94,44 @@
> KStringDict *stringDict;
> KLocale *locale;
> KCharsets *charsets;
> +
> + /**
> + * This componenent may be used instead of the main component for
> application
> + * That doesn't have a main componennt such as pure Qt
> application.
Typo man :D componenent -> component
>
> + */
> + static KComponentData initFakeComponent()
> + {
> + QString name = QCoreApplication::applicationName();
> + if(name.isEmpty())
> + name = qAppName();
> + if(name.isEmpty())
> + name = QString::fromLatin1("kde");
> + return KComponentData(name.toLatin1(), name.toLatin1(),
> +
> KComponentData::SkipMainComponentRegistration);
> + }
> };
>
> K_GLOBAL_STATIC(KGlobalPrivate, globalData)
> +K_GLOBAL_STATIC_WITH_ARGS(KComponentData, fakeComponent,
> (KGlobalPrivate::initFakeComponent()))
>
> #define PRIVATE_DATA KGlobalPrivate *d = globalData
>
> KStandardDirs *KGlobal::dirs()
> {
> PRIVATE_DATA;
> - MYASSERT(d->mainComponent.isValid());
> - return d->mainComponent.dirs();
> + return d->mainComponent.isValid() ? d->mainComponent.dirs() :
> fakeComponent->dirs();
> }
>
> KSharedConfig::Ptr KGlobal::config()
> {
> PRIVATE_DATA;
> - MYASSERT(d->mainComponent.isValid());
> - return d->mainComponent.config();
> + return d->mainComponent.isValid() ? d->mainComponent.config() :
> fakeComponent->config();
> }
>
> const KComponentData &KGlobal::mainComponent()
> {
> PRIVATE_DATA;
> - MYASSERT(d->mainComponent.isValid());
> - return d->mainComponent;
> + return d->mainComponent.isValid() ? d->mainComponent : *fakeComponent;
> }
>
> bool KGlobal::hasMainComponent()
> @@ -240,7 +254,7 @@
> return args->getOption("caption");
> } else {
> // We have some about data ?
> - if (d->mainComponent.aboutData()) {
> + if (d->mainComponent.isValid() && d->mainComponent.aboutData()) {
> return d->mainComponent.aboutData()->programName();
> } else {
> // Last resort : application name
>
[Attachment #3 (text/html)]
<br><br><div class="gmail_quote">On Mon, Feb 2, 2009 at 5:47 PM, Olivier Goffart \
<span dir="ltr"><<a href="mailto:ogoffart@kde.org">ogoffart@kde.org</a>></span> \
wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, \
204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> SVN commit 920285 by \
ogoffart:<br> <br>
Create a default KComponenentData if there is none.<br>
This is usefull for pure Qt applications that loads KDE plugins.<br>
<br>
KStyle and Oxygen actually worked around the problem but that can be removed<br>
QtCreator may crash when opening a file dialog because KFileDialog gets hooked by \
some designer plugin and, KFileDialog request KGlobal::config for many things.<br> \
<br>
BUG: 182861<br>
<br>
<br>
<br>
M +21 -7 kglobal.cpp<br>
<br>
<br>
--- trunk/KDE/kdelibs/kdecore/kernel/kglobal.cpp #920284:920285<br>
@@ -1,6 +1,7 @@<br>
/* This file is part of the KDE libraries<br>
Copyright (C) 1999 Sirtaj Singh Kanq <<a \
href="mailto:taj@kde.org">taj@kde.org</a>><br> Copyright (C) 2007 \
Matthias Kretz <<a href="mailto:kretz@kde.org">kretz@kde.org</a>><br> + \
Copyright (C) 2009 Olivier Goffart <<a \
href="mailto:ogoffart@kde.org">ogoffart@kde.org</a>><br> <br>
This library is free software; you can redistribute it and/or<br>
modify it under the terms of the GNU Library General Public<br>
@@ -93,31 +94,44 @@<br>
KStringDict *stringDict;<br>
KLocale *locale;<br>
KCharsets *charsets;<br>
+<br>
+ /**<br>
+ * This componenent may be used instead of the main \
component for application<br> + * That doesn't have a \
main componennt such as pure Qt application.</blockquote><div><br>Typo man :D \
componenent -> component<br> </div><blockquote class="gmail_quote" \
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;"> <br>
+ */<br>
+ static KComponentData initFakeComponent()<br>
+ {<br>
+ QString name = \
QCoreApplication::applicationName();<br> + \
if(name.isEmpty())<br> + \
name = qAppName();<br> + \
if(name.isEmpty())<br> + \
name = QString::fromLatin1("kde");<br> + \
return KComponentData(name.toLatin1(), name.toLatin1(),<br> + \
\
KComponentData::SkipMainComponentRegistration);<br> + \
}<br> };<br>
<br>
K_GLOBAL_STATIC(KGlobalPrivate, globalData)<br>
+K_GLOBAL_STATIC_WITH_ARGS(KComponentData, fakeComponent, \
(KGlobalPrivate::initFakeComponent()))<br> <br>
#define PRIVATE_DATA KGlobalPrivate *d = globalData<br>
<br>
KStandardDirs *KGlobal::dirs()<br>
{<br>
PRIVATE_DATA;<br>
- MYASSERT(d->mainComponent.isValid());<br>
- return d->mainComponent.dirs();<br>
+ return d->mainComponent.isValid() ? d->mainComponent.dirs() : \
fakeComponent->dirs();<br> }<br>
<br>
KSharedConfig::Ptr KGlobal::config()<br>
{<br>
PRIVATE_DATA;<br>
- MYASSERT(d->mainComponent.isValid());<br>
- return d->mainComponent.config();<br>
+ return d->mainComponent.isValid() ? d->mainComponent.config() : \
fakeComponent->config();<br> }<br>
<br>
const KComponentData &KGlobal::mainComponent()<br>
{<br>
PRIVATE_DATA;<br>
- MYASSERT(d->mainComponent.isValid());<br>
- return d->mainComponent;<br>
+ return d->mainComponent.isValid() ? d->mainComponent : \
*fakeComponent;<br> }<br>
<br>
bool KGlobal::hasMainComponent()<br>
@@ -240,7 +254,7 @@<br>
return args->getOption("caption");<br>
} else {<br>
// We have some about data ?<br>
- if (d->mainComponent.aboutData()) {<br>
+ if (d->mainComponent.isValid() && \
d->mainComponent.aboutData()) {<br> \
return d->mainComponent.aboutData()->programName();<br> \
} else {<br> // Last resort : \
application name<br> </blockquote></div><br>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic