Review Request 115485: Porting KTranscript from KJS to QtScript

Christoph Feck christoph at maxiom.de
Sat Feb 22 14:33:56 UTC 2014



> On Feb. 22, 2014, 1:35 p.m., Chusslove Illich wrote:
> > I tried to run a standalone non-GUI program using ki18n:
> > 
> >   #include <QDebug>
> >   #include <KLocalizedString>
> > 
> >   int main (int argc, char *argv[])
> >   {
> >       setlocale (LC_ALL, "");
> >       KLocalizedString::setApplicationDomain("test-ki18n-01");
> >       qDebug() << i18n("Delete %1?", i18n("file"));
> >       return 0;
> >   }
> > 
> > and got abort with this message:
> > 
> >   QScriptEngine: Must construct a Q(Core)Application before a QScriptEngine
> > 
> > It does work when I add only
> > 
> >   #include <QCoreApplication>
> >   ...
> >   QCoreApplication a(argc, argv);
> > 
> > What is the reason that this is necessary? If one does want to use ki18n in
> > non-Qt-UI program, would it be inappropriate (in whatever way) to
> > nevertheless require creation of QCoreApplication?
> >
> 
> Kevin Krammer wrote:
>     QCoreApplication is for non-UI Qt applications, QGuiApplication and its subclass QApplication are the ones for UI programs.
>     I was under the impression that translations always require the presence of a QCoreApplication (or derived) instance. Qt's own tr() does.
> 
> Alex Merry wrote:
>     And, indeed, there are a lot of other things in QtCore that break if you do not have a QCoreApplication instance.  In short, if you are making a Qt application (GUI or not), you need to create an instance of QCoreApplication (or one of its subclasses).
> 
> Chusslove Illich wrote:
>     To my knowledge there was no technical need for presence of QCoreApplication
>     in ki18n so far, e.g. the above example works with KJS.
>     
>     Also, what happens if one wants to place an i18n call before creating
>     Q*Application? We had such cases, and had to work around them in few ways.
>
> 
> Chusslove Illich wrote:
>     At any rate, hardly a show stopper.

As far as I know, we also had a kWarning() in kdelibs 4.x in case an application tries to use ki18n() before creating the application.


- Christoph


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/115485/#review50522
-----------------------------------------------------------


On Feb. 22, 2014, 2:15 p.m., Kevin Krammer wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/115485/
> -----------------------------------------------------------
> 
> (Updated Feb. 22, 2014, 2:15 p.m.)
> 
> 
> Review request for KDE Frameworks and Chusslove Illich.
> 
> 
> Repository: ki18n
> 
> 
> Description
> -------
> 
> Attempt at replacing the KJS dependency with a QtScript, i.e. making ki18n a tier1 framework.
> Needs more testing and likely fixing
> 
> 
> Diffs
> -----
> 
>   autotests/CMakeLists.txt c4d6b9b 
>   src/CMakeLists.txt 9e3ce9f 
>   src/ktranscript.cpp b9e0551 
>   CMakeLists.txt 06fb696 
> 
> Diff: https://git.reviewboard.kde.org/r/115485/diff/
> 
> 
> Testing
> -------
> 
> Unittest runs, but the test script is very minimal and would need to be extendedb by someone who understands the scripting requirements.
> There is also a weird crash at test shutdown, in QThreadStorage. As far as I can tell I did not change anything related to threads though.
> 
> 
> Thanks,
> 
> Kevin Krammer
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20140222/b33f80d5/attachment.html>


More information about the Kde-frameworks-devel mailing list