kde-menu: keep references to QByteArray objects

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2024-05-17 02:45:24 +03:00
parent 8a4df31980
commit 1f8c7b9f4d

View file

@ -39,18 +39,21 @@ static bool utf8 = false;
static bool bPrintMenuId = false; static bool bPrintMenuId = false;
static bool bPrintMenuName = false; static bool bPrintMenuName = false;
static QByteArray convert(const QString &txt)
{
return (utf8 ? txt.toUtf8() : txt.toLocal8Bit());
}
static void result(const QString &txt) static void result(const QString &txt)
{ {
if (utf8) { const QByteArray txtbytes = convert(txt);
puts(txt.toUtf8()); puts(txtbytes.constData());
} else {
puts(txt.toLocal8Bit());
}
} }
static void error(int exitCode, const QString &txt) static void error(int exitCode, const QString &txt)
{ {
qWarning("kde-menu: %s", txt.toLocal8Bit().data()); const QByteArray txtbytes = convert(txt);
qWarning("kde-menu: %s", txtbytes.constData());
exit(exitCode); exit(exitCode);
} }
@ -80,7 +83,6 @@ static void findMenuEntry(KServiceGroup::Ptr parent, const QString &name, const
} }
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
const char *description = I18N_NOOP( const char *description = I18N_NOOP(