mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-19 04:20:09 +00:00
7b48e2aac0
This is needed since src/support calls lots of qt code, and some parts of it (e.g. QFileInfo) require a running event loop. This fixes bug #4917 which is a symptom of the problem. The fix is to create a QCoreApplication for tex2lyx, lyxclient and LyX running without GUI. In the future this could be extended, i.e. to split up the frontend Application class in a GUI and a console class, and having the console class use LyXConsoleApp in the same way as Application now uses GuiApplication. If that is done, one could also think of moving support/ConsoleApplication to frontend/console/ConsoleApplication.
65 lines
1.2 KiB
C++
65 lines
1.2 KiB
C++
/**
|
|
* \file ConsoleApplicationPrivate.h
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author Georg Baum
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#ifndef CONSOPLEAPPLICATIONPRIVATE_H
|
|
#define CONSOPLEAPPLICATIONPRIVATE_H
|
|
|
|
#include "support/qstring_helpers.h"
|
|
|
|
#include <QCoreApplication>
|
|
#include <QDateTime>
|
|
#include <QTimer>
|
|
|
|
#include <string>
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace support {
|
|
|
|
class ConsoleApplication;
|
|
|
|
class ConsoleApplicationPrivate : public QCoreApplication
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
ConsoleApplicationPrivate(ConsoleApplication * owner,
|
|
std::string const & app, int & argc, char ** argv)
|
|
: QCoreApplication(argc, argv), owner_(owner)
|
|
{
|
|
setOrganizationName("LyX");
|
|
setOrganizationDomain("lyx.org");
|
|
setApplicationName(toqstr(app));
|
|
|
|
qsrand(QDateTime::currentDateTime().toTime_t());
|
|
}
|
|
int execute()
|
|
{
|
|
// set timer to do the work asynchronously after the event
|
|
// loop was started
|
|
QTimer::singleShot(0, this, SLOT(doExec()));
|
|
// start event loop
|
|
return exec();
|
|
}
|
|
private Q_SLOTS:
|
|
void doExec()
|
|
{
|
|
owner_->doExec();
|
|
}
|
|
private:
|
|
ConsoleApplication * owner_;
|
|
};
|
|
|
|
|
|
} // namespace support
|
|
} // namespace lyx
|
|
|
|
#endif // CONSOPLEAPPLICATIONPRIVATE_H
|