Commit 247c71ce authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents aa3d7ba2 c03ab703
......@@ -31,6 +31,7 @@
#include "WApplication.h"
#include "core/common/WException.h"
#include "core/common/WLogger.h"
#define OPENWALNUT_BUGREPORTER_URL "http://www.openwalnut.org/projects/openwalnut/issues"
......@@ -47,57 +48,42 @@ void WApplication::setMyMainWidget( QWidget* widget )
bool WApplication::notify( QObject* object, QEvent* event )
{
// Question: can we assume that WLogger is running here?
// if so, we should log the message to the logger as well.
bool retval = false;
try
QString exception_msg;
try // do the default action, but catch exceptions
{
// do the default action, but catch exceptions
retval = QApplication::notify( object, event );
}
catch( const WException &we )
{
QMessageBox msgBox( myMainWidget );
msgBox.setIcon( QMessageBox::Critical );
msgBox.setInformativeText( tr( "An uncaught exception occurred which may be due to a corrupt installation or a programming bug. "
"Please check the openwalnut bug reporter for similar tickets and report the "
"issue including the following text:<br><br><i>" )
+ we.what() +
"</i><br><br>Please report to<br><a href=\""
OPENWALNUT_BUGREPORTER_URL
"\">" OPENWALNUT_BUGREPORTER_URL "</a>" );
msgBox.setText( tr( "Uncaught Exception" ) );
QPushButton* websiteButton = msgBox.addButton( tr( "Go to web site" ), QMessageBox::ActionRole );
msgBox.setStandardButtons( QMessageBox::Ignore );
msgBox.setEscapeButton( QMessageBox::Ignore );
msgBox.exec();
if( msgBox.clickedButton() == websiteButton )
{
/* bool success = */ QDesktopServices::openUrl( QUrl( OPENWALNUT_BUGREPORTER_URL ) );
}
exception_msg = QString( we.what() );
}
catch( const std::exception &se )
{
exception_msg = QString( se.what() );
}
if( !exception_msg.isEmpty() )
{
QMessageBox msgBox( myMainWidget );
msgBox.setIcon( QMessageBox::Critical );
msgBox.setInformativeText( tr( "An uncaught exception occurred which may be due to a corrupt installation or a programming bug. "
"Please check the openwalnut bug reporter for similar tickets and report the "
"issue including the following text:<br><br><i>" )
+ se.what() +
"</i><br><br>Please report to<br><a href=\""
OPENWALNUT_BUGREPORTER_URL
"\">" OPENWALNUT_BUGREPORTER_URL "</a>" );
msgBox.setText( tr( "Uncaught Exception" ) );
QString info( "An uncaught exception occurred which may be due to a corrupt installation or a programming bug. "
"Please check the openwalnut bug reporter for similar tickets and report the issue including the "
"following text: <br><br><i>" + exception_msg + "</i><br><br> Please report to: <br><a href=\""
OPENWALNUT_BUGREPORTER_URL "\">" OPENWALNUT_BUGREPORTER_URL "</a>" );
msgBox.setInformativeText( tr( info.toStdString().c_str() ) );
QPushButton* websiteButton = msgBox.addButton( tr( "Go to web site" ), QMessageBox::ActionRole );
msgBox.setStandardButtons( QMessageBox::Ignore );
msgBox.setEscapeButton( QMessageBox::Ignore );
msgBox.exec();
if( msgBox.clickedButton() == websiteButton )
{
/* bool success = */ QDesktopServices::openUrl( QUrl( OPENWALNUT_BUGREPORTER_URL ) );
QDesktopServices::openUrl( QUrl( OPENWALNUT_BUGREPORTER_URL ) ); // we do not have use for the bool return value
}
// also notify the logger, as it is setup, before WApplication::exec is called
wlog::error( "WApplication" ) << info.remove( QRegExp( "<[^>]*>" ) ).toStdString();
}
return retval;
}
......@@ -680,7 +680,14 @@ QString collectFilters()
result += description + QString( "(*" ) + extension + QString( ");;" );
}
return QString( "Known file types (" ) + all + QString( ");;" ) + result;
// math: on 11. Aug. 2015, related issue: http://www.openwalnut.org/issues/404
// The following #ifdef is due to the following QT-Bug: https://bugreports.qt.io/browse/QTBUG-38303
// Hence, we use any file as known file type for MAC OSX only.
#ifdef Q_OS_OSX
return QString( "Known file types (* " ) + all + QString( ");;" ) + result;
#else
return QString( "Known file types (" ) + all + QString( ");;" ) + result;
#endif
}
void WMainWindow::openLoadDialog()
......
......@@ -34,6 +34,7 @@
#include <QApplication>
#include <QSplashScreen>
#include <QFileDialog>
#include <QtGlobal> // for QCoreApplication::setAttribute
#include <QtCore/QDir>
#include <QtCore/QSettings>
......@@ -64,11 +65,6 @@
#include "WQtGui.h"
#ifdef Q_WS_X11
#include <X11/Xlib.h> // NOLINT - this needs to be done AFTER Qt has set some defines in their headers and after several other
// headers which are included indirectly, although it is a system header.
#endif
WMainWindow* WQtGui::m_mainWindow = NULL;
QSettings* WQtGui::m_settings = NULL;
......@@ -78,6 +74,7 @@ WQtGui::WQtGui( const boost::program_options::variables_map& options, int argc,
m_optionsMap( options ),
m_loadDeferredOnce( true )
{
QCoreApplication::setAttribute( Qt::AA_X11InitThreads );
}
WQtGui::~WQtGui()
......@@ -153,40 +150,28 @@ void WQtGui::deferredLoad()
int WQtGui::run()
{
#ifdef Q_WS_X11
XInitThreads();
#endif
m_splash = NULL;
// init logger
m_loggerConnection = WLogger::getLogger()->subscribeSignal( WLogger::AddLog, boost::bind( &WQtGui::slotAddLog, this, _1 ) );
// make qapp instance before using the applicationDirPath() function
#ifdef Q_WS_MAC
//TODO(mario): this should run on all platforms but crashes at least on Linux right now. Therefore, I only use it on OSX
WApplication appl( m_argc, m_argv, true );
#else
// TODO(mario): I want a WApplication here for session handling but that code crashes
QApplication appl( m_argc, m_argv, true );
#endif
// the call path of the application, this uses QApplication which needs to be instantiated.
boost::filesystem::path walnutBin = boost::filesystem::path( QApplication::applicationDirPath().toStdString() );
// setup path helper which provides several paths to others
#ifdef Q_WS_MAC
#ifdef Q_OS_OSX
// apple has a special file hierarchy in so-called bundles
// this code determines whether we are started from a bundle context
// and sets the paths according to Apple's guidelines inside the bundle
if( QApplication::applicationDirPath().endsWith( "/MacOS" ) )
if( QApplication::applicationDirPath().endsWith( "/MacOS" ) ) // we are in a bundle
{
// we are in a bundle
// TODO(mario): apply default OSX behavior of using $HOME/Library/OpenWalnut ?
WPathHelper::getPathHelper()->setBasePathsOSXBundle( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" );
}
else
else // assume standard behavior
{
// assume standard behavior
WPathHelper::getPathHelper()->setBasePaths( walnutBin, boost::filesystem::path( QDir::homePath().toStdString() ) / ".OpenWalnut" );
}
#else
......@@ -263,10 +248,7 @@ int WQtGui::run()
m_widgetFactory = WUIQtWidgetFactory::SPtr( new WUIQtWidgetFactory( m_mainWindow ) );
#ifdef Q_WS_MAC
//TODO(mario): this should run on all platforms but crashes at least on Linux right now. Therefore, I only use it on OSX
appl.setMyMainWidget( m_mainWindow );
#endif
m_mainWindow->setupGUI();
m_mainWindow->show();
......
......@@ -61,7 +61,7 @@ int WScriptUI::run()
boost::filesystem::path homePath = boost::filesystem::path( getenv( "HOME" ) );
// setup path helper which provides several paths to others
#ifdef Q_WS_MAC
#ifdef Q_OS_OSX
// apple has a special file hierarchy in so-called bundles
// this code determines whether we are started from a bundle context
// and sets the paths according to Apple's guidelines inside the bundle
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment