Commit c03ab703 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[REMOVED] Apple #ifdefs concerning WApplication and QApplication were obsolete...

[REMOVED] Apple #ifdefs concerning WApplication and QApplication were obsolete by now. Tested on Linux (Debian unstable) and Mac OS 10.10.4.
parent 47c2c86f
......@@ -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;
}
......@@ -155,13 +155,7 @@ int WQtGui::run()
m_loggerConnection = WLogger::getLogger()->subscribeSignal( WLogger::AddLog, boost::bind( &WQtGui::slotAddLog, this, _1 ) );
// make qapp instance before using the applicationDirPath() function
#ifdef Q_OS_OSX
//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() );
......@@ -171,15 +165,13 @@ int WQtGui::run()
// 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
......@@ -256,10 +248,7 @@ int WQtGui::run()
m_widgetFactory = WUIQtWidgetFactory::SPtr( new WUIQtWidgetFactory( m_mainWindow ) );
#ifdef Q_OS_OSX
//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();
......
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