Create a standard function to init Hifi Apps

This commit is contained in:
Atlante45 2018-02-22 16:22:18 -08:00
parent 80c0f2a21e
commit 277e556b48
27 changed files with 88 additions and 160 deletions

View file

@ -9,25 +9,13 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <LogHandler.h>
#include <BuildInfo.h>
#include <SharedUtil.h>
#include "AssignmentClientApp.h"
#include <BuildInfo.h>
int main(int argc, char* argv[]) {
disableQtBearerPoll(); // Fixes wifi ping spikes
QCoreApplication::setApplicationName(BuildInfo::ASSIGNMENT_CLIENT_NAME);
QCoreApplication::setOrganizationName(BuildInfo::MODIFIED_ORGANIZATION);
QCoreApplication::setOrganizationDomain(BuildInfo::ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationVersion(BuildInfo::VERSION);
setupGlobalInstances();
qInstallMessageHandler(LogHandler::verboseMessageHandler);
qInfo() << "Starting.";
setupHifiApplication(BuildInfo::ASSIGNMENT_CLIENT_NAME);
AssignmentClientApp app(argc, argv);

View file

@ -22,24 +22,10 @@
#include "DomainServer.h"
int main(int argc, char* argv[]) {
disableQtBearerPoll(); // Fixes wifi ping spikes
setupHifiApplication(BuildInfo::DOMAIN_SERVER_NAME);
QCoreApplication::setApplicationName(BuildInfo::DOMAIN_SERVER_NAME);
QCoreApplication::setOrganizationName(BuildInfo::MODIFIED_ORGANIZATION);
QCoreApplication::setOrganizationDomain(BuildInfo::ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationVersion(BuildInfo::VERSION);
setupGlobalInstances();
Setting::init();
#ifndef WIN32
setvbuf(stdout, NULL, _IOLBF, 0);
#endif
qInstallMessageHandler(LogHandler::verboseMessageHandler);
qInfo() << "Starting.";
int currentExitCode = 0;
// use a do-while to handle domain-server restart

View file

@ -11,18 +11,13 @@
#include <QtCore/QCoreApplication>
#include <LogHandler.h>
#include <SharedUtil.h>
#include "IceServer.h"
int main(int argc, char* argv[]) {
#ifndef WIN32
setvbuf(stdout, NULL, _IOLBF, 0);
#endif
qInstallMessageHandler(LogHandler::verboseMessageHandler);
qInfo() << "Starting.";
setupHifiApplication("Ice Server");
IceServer iceServer(argc, argv);
return iceServer.exec();
}
}

View file

@ -575,10 +575,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType) type, context, message);
if (!logMessage.isEmpty()) {
#ifdef Q_OS_WIN
OutputDebugStringA(logMessage.toLocal8Bit().constData());
OutputDebugStringA("\n");
#elif defined Q_OS_ANDROID
#ifdef Q_OS_ANDROID
const char * local=logMessage.toStdString().c_str();
switch (type) {
case QtDebugMsg:
@ -599,7 +596,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt
abort();
}
#endif
qApp->getLogger()->addMessage(qPrintable(logMessage + "\n"));
qApp->getLogger()->addMessage(qPrintable(logMessage));
}
}

View file

@ -38,6 +38,7 @@ extern "C" {
#endif
int main(int argc, const char* argv[]) {
setupHifiApplication(BuildInfo::INTERFACE_NAME);
#ifdef Q_OS_LINUX
QApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
@ -51,19 +52,9 @@ int main(int argc, const char* argv[]) {
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
disableQtBearerPoll(); // Fixes wifi ping spikes
QElapsedTimer startupTime;
startupTime.start();
// Set application infos
QCoreApplication::setApplicationName(BuildInfo::INTERFACE_NAME);
QCoreApplication::setOrganizationName(BuildInfo::MODIFIED_ORGANIZATION);
QCoreApplication::setOrganizationDomain(BuildInfo::ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationVersion(BuildInfo::VERSION);
setupGlobalInstances();
Setting::init();
// Instance UserActivityLogger now that the settings are loaded

View file

@ -14,6 +14,10 @@
#include <mutex>
#ifdef Q_OS_WIN
#include <windows.h>
#endif
#include <QtCore/QCoreApplication>
#include <QtCore/QDateTime>
#include <QtCore/QDebug>
@ -184,8 +188,12 @@ QString LogHandler::printMessage(LogMsgType type, const QMessageLogContext& cont
}
}
QString logMessage = QString("%1 %2").arg(prefixString, message.split('\n').join('\n' + prefixString + " "));
fprintf(stdout, "%s\n", qPrintable(logMessage));
QString logMessage = QString("%1 %2\n").arg(prefixString, message.split('\n').join('\n' + prefixString + " "));
fprintf(stdout, "%s", qPrintable(logMessage));
#ifdef Q_OS_WIN
OutputDebugStringA(qPrintable(logMessage));
#endif
return logMessage;
}

View file

@ -59,6 +59,9 @@ extern "C" FILE * __cdecl __iob_func(void) {
#include <QSysInfo>
#include <QThread>
#include <BuildInfo.h>
#include "LogHandler.h"
#include "NumericalConstants.h"
#include "OctalCode.h"
#include "SharedLogging.h"
@ -1179,6 +1182,23 @@ void watchParentProcess(int parentPID) {
}
#endif
void setupHifiApplication(QString applicationName) {
disableQtBearerPoll(); // Fixes wifi ping spikes
QCoreApplication::setApplicationName(applicationName);
QCoreApplication::setOrganizationName(BuildInfo::MODIFIED_ORGANIZATION);
QCoreApplication::setOrganizationDomain(BuildInfo::ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationVersion(BuildInfo::VERSION);
setupGlobalInstances();
#ifndef WIN32
setvbuf(stdout, NULL, _IOLBF, 0);
#endif
qInstallMessageHandler(LogHandler::verboseMessageHandler);
qInfo() << "Starting.";
}
#ifdef Q_OS_WIN
QString getLastErrorAsString() {

View file

@ -228,6 +228,7 @@ void watchParentProcess(int parentPID);
bool processIsRunning(int64_t pid);
void setupHifiApplication(QString applicationName);
#ifdef Q_OS_WIN
void* createProcessGroup();

View file

@ -20,6 +20,7 @@
#include <EntityItemProperties.h>
#include <Octree.h>
#include <PathUtils.h>
#include <SharedUtil.h>
const QString& getTestResourceDir() {
static QString dir;
@ -136,6 +137,8 @@ void testPropertyFlags() {
}
int main(int argc, char** argv) {
setupHifiApplication("Entities Test");
QCoreApplication app(argc, argv);
{
auto start = usecTimestampNow();

View file

@ -45,6 +45,7 @@
#include <TextureCache.h>
#include <PerfStat.h>
#include <PathUtils.h>
#include <SharedUtil.h>
#include <ViewFrustum.h>
#include <gpu/Pipeline.h>
@ -192,7 +193,9 @@ void testSparseRectify() {
}
}
int main(int argc, char** argv) {
int main(int argc, char** argv) {
setupHifiApplication("GPU Test");
testSparseRectify();
// FIXME this test appears to be broken

View file

@ -149,7 +149,8 @@ static const QString TEST_FOLDER { "H:/ktx_cacheold" };
static const QString EXTENSIONS { "*.ktx" };
int mainTemp(int, char**) {
qInstallMessageHandler(messageHandler);
setupHifiApplication("KTX Tests");
auto fileInfoList = QDir { TEST_FOLDER }.entryInfoList(QStringList { EXTENSIONS });
for (auto fileInfo : fileInfoList) {
qDebug() << fileInfo.filePath();

View file

@ -179,18 +179,10 @@ void TestWindow::resizeEvent(QResizeEvent* ev) {
resizeWindow(ev->size());
}
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
if (!message.isEmpty()) {
#ifdef Q_OS_WIN
OutputDebugStringA(message.toLocal8Bit().constData());
OutputDebugStringA("\n");
#endif
}
}
int main(int argc, char** argv) {
setupHifiApplication("QML Test");
int main(int argc, char** argv) {
QGuiApplication app(argc, argv);
qInstallMessageHandler(messageHandler);
TestWindow window;
app.exec();
return 0;

View file

@ -63,14 +63,11 @@ void Qt59TestApp::finish(int exitCode) {
int main(int argc, char * argv[]) {
QCoreApplication::setApplicationName("Qt59Test");
QCoreApplication::setOrganizationName(BuildInfo::MODIFIED_ORGANIZATION);
QCoreApplication::setOrganizationDomain(BuildInfo::ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationVersion(BuildInfo::VERSION);
setupHifiApplication("Qt59Test");
Qt59TestApp app(argc, argv);
return app.exec();
}
#include "main.moc"
#include "main.moc"

View file

@ -10,6 +10,8 @@
#include <recording/Clip.h>
#include <recording/Frame.h>
#include <SharedUtil.h>
#include "Constants.h"
using namespace recording;
@ -97,18 +99,10 @@ void testClipOrdering() {
Q_UNUSED(lastFrameTimeOffset); // FIXME - Unix build not yet upgraded to Qt 5.5.1 we can remove this once it is
}
#ifdef Q_OS_WIN32
void myMessageHandler(QtMsgType type, const QMessageLogContext & context, const QString & msg) {
OutputDebugStringA(msg.toLocal8Bit().toStdString().c_str());
OutputDebugStringA("\n");
}
#endif
int main(int, const char**) {
#ifdef Q_OS_WIN32
qInstallMessageHandler(myMessageHandler);
#endif
setupHifiApplication("Recording Test");
testFrameTypeRegistration();
testFilePersist();
testClipOrdering();
}
}

View file

@ -1138,31 +1138,17 @@ private:
bool QTestWindow::_cullingEnabled = true;
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
QString logMessage = LogHandler::getInstance().printMessage((LogMsgType)type, context, message);
if (!logMessage.isEmpty()) {
#ifdef Q_OS_WIN
OutputDebugStringA(logMessage.toLocal8Bit().constData());
OutputDebugStringA("\n");
#endif
logger->addMessage(qPrintable(logMessage + "\n"));
}
}
const char * LOG_FILTER_RULES = R"V0G0N(
hifi.gpu=true
)V0G0N";
int main(int argc, char** argv) {
setupHifiApplication("RenderPerf");
QApplication app(argc, argv);
QCoreApplication::setApplicationName("RenderPerf");
QCoreApplication::setOrganizationName("High Fidelity");
QCoreApplication::setOrganizationDomain("highfidelity.com");
logger.reset(new FileLogger());
qInstallMessageHandler(messageHandler);
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
QTestWindow::setup();
QTestWindow window;

View file

@ -610,16 +610,6 @@ private:
bool _ready { false };
};
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
if (!message.isEmpty()) {
#ifdef Q_OS_WIN
OutputDebugStringA(message.toLocal8Bit().constData());
OutputDebugStringA("\n");
#endif
std::cout << message.toLocal8Bit().constData() << std::endl;
}
}
const char * LOG_FILTER_RULES = R"V0G0N(
hifi.gpu=true
)V0G0N";
@ -645,11 +635,9 @@ void unzipTestData(const QByteArray& zipData) {
}
int main(int argc, char** argv) {
setupHifiApplication("RenderPerf");
QApplication app(argc, argv);
QCoreApplication::setApplicationName("RenderPerf");
QCoreApplication::setOrganizationName("High Fidelity");
QCoreApplication::setOrganizationDomain("highfidelity.com");
qInstallMessageHandler(messageHandler);
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
if (!DATA_DIR.exists()) {

View file

@ -179,25 +179,14 @@ void QTestWindow::draw() {
}
}
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
if (!message.isEmpty()) {
#ifdef Q_OS_WIN
OutputDebugStringA(message.toLocal8Bit().constData());
OutputDebugStringA("\n");
#else
std::cout << message.toLocal8Bit().constData() << std::endl;
#endif
}
}
const char * LOG_FILTER_RULES = R"V0G0N(
hifi.gpu=true
)V0G0N";
int main(int argc, char** argv) {
int main(int argc, char** argv) {
setupHifiApplication("Render Utils Test");
QGuiApplication app(argc, argv);
qInstallMessageHandler(messageHandler);
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
QTestWindow window;
QTimer timer;

View file

@ -214,24 +214,14 @@ void QTestWindow::draw() {
_context.swapBuffers(this);
}
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
if (!message.isEmpty()) {
#ifdef Q_OS_WIN
OutputDebugStringA(message.toLocal8Bit().constData());
OutputDebugStringA("\n");
#else
std::cout << message.toLocal8Bit().constData() << std::endl;
#endif
}
}
const char * LOG_FILTER_RULES = R"V0G0N(
hifi.gpu=true
)V0G0N";
int main(int argc, char** argv) {
int main(int argc, char** argv) {
setupHifiApplication("Shaders Test");
QGuiApplication app(argc, argv);
qInstallMessageHandler(messageHandler);
QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
QTestWindow window;
QTimer timer;

View file

@ -20,12 +20,7 @@
using namespace std;
int main(int argc, char* argv[]) {
QCoreApplication::setApplicationName(BuildInfo::AC_CLIENT_SERVER_NAME);
QCoreApplication::setOrganizationName(BuildInfo::MODIFIED_ORGANIZATION);
QCoreApplication::setOrganizationDomain(BuildInfo::ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationVersion(BuildInfo::VERSION);
setupGlobalInstances();
setupHifiApplication(BuildInfo::AC_CLIENT_SERVER_NAME);
Setting::init();

View file

@ -20,12 +20,7 @@
using namespace std;
int main(int argc, char * argv[]) {
QCoreApplication::setApplicationName(BuildInfo::AC_CLIENT_SERVER_NAME);
QCoreApplication::setOrganizationName(BuildInfo::MODIFIED_ORGANIZATION);
QCoreApplication::setOrganizationDomain(BuildInfo::ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationVersion(BuildInfo::VERSION);
setupGlobalInstances();
setupHifiApplication("ATP Client");
Setting::init();

View file

@ -17,4 +17,4 @@ int main(int argc, char *argv[]) {
autoTester.show();
return application.exec();
}
}

View file

@ -13,11 +13,15 @@
#include <string>
#include <vector>
#include <SharedUtil.h>
#include "ICEClientApp.h"
using namespace std;
int main(int argc, char * argv[]) {
setupHifiApplication("ICE Client");
ICEClientApp app(argc, argv);
return app.exec();
}

View file

@ -15,12 +15,7 @@
#include <SharedUtil.h>
int main (int argc, char** argv) {
QCoreApplication::setApplicationName("Oven");
QCoreApplication::setOrganizationName(BuildInfo::MODIFIED_ORGANIZATION);
QCoreApplication::setOrganizationDomain(BuildInfo::ORGANIZATION_DOMAIN);
QCoreApplication::setApplicationVersion(BuildInfo::VERSION);
setupGlobalInstances();
setupHifiApplication("Oven");
// init the settings interface so we can save and load settings
Setting::init();

View file

@ -14,9 +14,13 @@
#include <vector>
#include <QDebug>
#include <SharedUtil.h>
#include "SkeletonDumpApp.h"
int main(int argc, char * argv[]) {
setupHifiApplication("Skeleton Dump App");
SkeletonDumpApp app(argc, argv);
return app.getReturnCode();
}

View file

@ -71,8 +71,6 @@ const QStringList SERVER_STATS_TABLE_HEADERS {
UDTTest::UDTTest(int& argc, char** argv) :
QCoreApplication(argc, argv)
{
qInstallMessageHandler(LogHandler::verboseMessageHandler);
parseArguments();
// randomize the seed for packet size randomization

View file

@ -10,9 +10,13 @@
#include <QtCore/QCoreApplication>
#include <SharedUtil.h>
#include "UDTTest.h"
int main(int argc, char* argv[]) {
setupHifiApplication("UDT Test);
UDTTest app(argc, argv);
return app.exec();
}

View file

@ -15,6 +15,8 @@
#include <string>
#include <vector>
#include <SharedUtil.h>
#include "VHACDUtilApp.h"
using namespace std;
@ -22,6 +24,8 @@ using namespace VHACD;
int main(int argc, char * argv[]) {
setupHifiApplication("VHACD Util");
VHACDUtilApp app(argc, argv);
return app.getReturnCode();
}