[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">&lt;<a href="mailto:ogoffart@kde.org">ogoffart@kde.org</a>&gt;</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>
&nbsp;M &nbsp;+21 -7 &nbsp; &nbsp; kglobal.cpp<br>
<br>
<br>
--- trunk/KDE/kdelibs/kdecore/kernel/kglobal.cpp #920284:920285<br>
@@ -1,6 +1,7 @@<br>
&nbsp;/* This file is part of the KDE libraries<br>
 &nbsp; &nbsp;Copyright (C) 1999 Sirtaj Singh Kanq &lt;<a \
href="mailto:taj@kde.org">taj@kde.org</a>&gt;<br>  &nbsp; &nbsp;Copyright (C) 2007 \
Matthias Kretz &lt;<a href="mailto:kretz@kde.org">kretz@kde.org</a>&gt;<br> + &nbsp; \
Copyright (C) 2009 Olivier Goffart &lt;<a \
href="mailto:ogoffart@kde.org">ogoffart@kde.org</a>&gt;<br> <br>
 &nbsp; &nbsp;This library is free software; you can redistribute it and/or<br>
 &nbsp; &nbsp;modify it under the terms of the GNU Library General Public<br>
@@ -93,31 +94,44 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp; KStringDict *stringDict;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; KLocale *locale;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; KCharsets *charsets;<br>
+<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;/**<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; * This componenent may be used instead of the main \
component for application<br> + &nbsp; &nbsp; &nbsp; &nbsp; * That doesn&#39;t have a \
main componennt such as pure Qt application.</blockquote><div><br>Typo man :D \
componenent -&gt; component<br>&nbsp;</div><blockquote class="gmail_quote" \
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; \
padding-left: 1ex;"> <br>
+ &nbsp; &nbsp; &nbsp; &nbsp; */<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;static KComponentData initFakeComponent()<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;{<br>
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;QString name = \
QCoreApplication::applicationName();<br> + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;if(name.isEmpty())<br> + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;name = qAppName();<br> + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;if(name.isEmpty())<br> + &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp;name = QString::fromLatin1(&quot;kde&quot;);<br> + &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp;return KComponentData(name.toLatin1(), name.toLatin1(),<br> + &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp;KComponentData::SkipMainComponentRegistration);<br> + \
&nbsp; &nbsp; &nbsp; &nbsp;}<br> &nbsp;};<br>
<br>
&nbsp;K_GLOBAL_STATIC(KGlobalPrivate, globalData)<br>
+K_GLOBAL_STATIC_WITH_ARGS(KComponentData, fakeComponent, \
(KGlobalPrivate::initFakeComponent()))<br> <br>
&nbsp;#define PRIVATE_DATA KGlobalPrivate *d = globalData<br>
<br>
&nbsp;KStandardDirs *KGlobal::dirs()<br>
&nbsp;{<br>
 &nbsp; &nbsp; PRIVATE_DATA;<br>
- &nbsp; &nbsp;MYASSERT(d-&gt;mainComponent.isValid());<br>
- &nbsp; &nbsp;return d-&gt;mainComponent.dirs();<br>
+ &nbsp; &nbsp;return d-&gt;mainComponent.isValid() ? d-&gt;mainComponent.dirs() : \
fakeComponent-&gt;dirs();<br> &nbsp;}<br>
<br>
&nbsp;KSharedConfig::Ptr KGlobal::config()<br>
&nbsp;{<br>
 &nbsp; &nbsp; PRIVATE_DATA;<br>
- &nbsp; &nbsp;MYASSERT(d-&gt;mainComponent.isValid());<br>
- &nbsp; &nbsp;return d-&gt;mainComponent.config();<br>
+ &nbsp; &nbsp;return d-&gt;mainComponent.isValid() ? d-&gt;mainComponent.config() : \
fakeComponent-&gt;config();<br> &nbsp;}<br>
<br>
&nbsp;const KComponentData &amp;KGlobal::mainComponent()<br>
&nbsp;{<br>
 &nbsp; &nbsp; PRIVATE_DATA;<br>
- &nbsp; &nbsp;MYASSERT(d-&gt;mainComponent.isValid());<br>
- &nbsp; &nbsp;return d-&gt;mainComponent;<br>
+ &nbsp; &nbsp;return d-&gt;mainComponent.isValid() ? d-&gt;mainComponent : \
*fakeComponent;<br> &nbsp;}<br>
<br>
&nbsp;bool KGlobal::hasMainComponent()<br>
@@ -240,7 +254,7 @@<br>
 &nbsp; &nbsp; &nbsp; &nbsp; return args-&gt;getOption(&quot;caption&quot;);<br>
 &nbsp; &nbsp; } else {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; // We have some about data ?<br>
- &nbsp; &nbsp; &nbsp; &nbsp;if (d-&gt;mainComponent.aboutData()) {<br>
+ &nbsp; &nbsp; &nbsp; &nbsp;if (d-&gt;mainComponent.isValid() &amp;&amp; \
d-&gt;mainComponent.aboutData()) {<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \
return d-&gt;mainComponent.aboutData()-&gt;programName();<br>  &nbsp; &nbsp; &nbsp; \
&nbsp; } else {<br>  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 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