Commit 6fa3043c authored by ledig's avatar ledig

corrected stylesheet thx to win

parent 4a2b7f9b
......@@ -61,7 +61,8 @@ void WThreadedRunner::run()
m_Thread = this;
Init();
start();
} else
}
else
{
threadMain();
}
......
......@@ -25,21 +25,23 @@
#ifndef WTHREADEDRUNNER_H
#define WTHREADEDRUNNER_H
#if defined( WIN32 )
#ifdef _WIN32
#define USE_BOOST_THREADS 0
#else
#define USE_BOOST_THREADS 1
#endif
#if USE_BOOST_THREADS
#include <boost/thread.hpp>
#include <boost/thread/thread.hpp>
#else
#if !USE_BOOST_THREADS
#include <OpenThreads/Thread>
#endif
#include <boost/function.hpp>
#if USE_BOOST_THREADS
#include <boost/thread.hpp>
#include <boost/thread/thread.hpp>
#endif
#include "WFlag.h"
/**
......@@ -47,9 +49,94 @@
*/
#if USE_BOOST_THREADS
class WThreadedRunner
{
public:
/**
* Type used for simple thread functions.
*/
typedef boost::function< void ( void ) > THREADFUNCTION;
/**
* Default constructor.
*/
WThreadedRunner();
/**
* Destructor.
*/
virtual ~WThreadedRunner();
/**
* Run thread.
*/
virtual void run();
/**
* Run thread. This does not start threadMain(() but runs a specified function instead.
*
* \param f the function to run instead of the threadMain method.
*/
void run( THREADFUNCTION f );
/**
* Wait for the thread to be finished.
*
* \param requestFinish true if the thread should be notified.
*/
void wait( bool requestFinish = false );
protected:
/**
* Function that has to be overwritten for execution. It gets executed in a separate thread after run()
* has been called.
*/
virtual void threadMain();
/**
* Gets called when the thread should be stopped.
*/
virtual void notifyStop();
/**
* Thread instance.
*/
boost::thread* m_Thread;
/**
* True if thread should end execution. NOTE: do not use this. Use m_shutdownFlag instead.
*/
bool m_FinishRequested;
/**
* Give remaining execution timeslice to another thread.
*/
void yield() const;
/**
* Sets thread asleep.
*
* \param t time to sleep in seconds.
*/
void sleep( const int t ) const;
/**
* Let the thread sleep until a stop request was given.
*/
void waitForStop();
/**
* Condition getting fired whenever the thread should quit. This is useful for waiting for stop requests.
*/
WBoolFlag m_shutdownFlag;
private:
};
#else
class WThreadedRunner : OpenThreads::Thread
#endif
{
public:
......@@ -103,13 +190,9 @@ protected:
/**
* Thread instance.
*/
#if USE_BOOST_THREADS
boost::thread* m_Thread;
#else
OpenThreads::Thread *m_Thread;
bool m_firstRun;
#endif
/**
* True if thread should end execution. NOTE: do not use this. Use m_shutdownFlag instead.
......@@ -140,6 +223,7 @@ protected:
private:
};
#endif // USE_BOOST_THREAD
#endif // WTHREADEDRUNNER_H
......@@ -24,7 +24,7 @@
#include <string>
#include <boost/filesystem.hpp>
#include <boost/filesystem.hpp>
#include "../kernel/WKernel.h"
......
......@@ -28,7 +28,7 @@
#include <string>
#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
......
......@@ -95,7 +95,7 @@ void WQtRibbonMenu::clearNonPersistentTabs()
}
m_tabWidget->removeTab( idx );
m_tabList.erase( iter++ );
}
}
else
{
++iter;
......
......@@ -35,7 +35,7 @@
#include <string>
#include <vector>
#include <boost/filesystem.hpp>
#include <boost/filesystem.hpp>
#include <boost/thread/xtime.hpp>
#include "WModule.h"
......@@ -177,90 +177,13 @@ void WKernel::findAppPath()
// unified version with boost::filesystem
namespace fs = boost::filesystem;
fs::path currentDir( fs::initial_path<fs::path>() );
fs::path currentDir( fs::initial_path<fs::path>() );
m_AppPath = currentDir.file_string();
// std::cout << "Set app path to " << m_AppPath << std::endl;
m_shaderPath = fs::path( currentDir / "shaders" ).file_string();
// std::cout << "Set shader path to " << m_shaderPath << std::endl;
/*
// FIXME (schurade)
// this should work on linux, have to implement it for windows and mac later
#ifdef __linux__
// This might be the better alternative to the below code but it does not print the path to the executable, but to the current
// working directory, which in the unix world is the better choice as path
char* appPath = get_current_dir_name();
// int length;
//char appPath[255];
//length = readlink( "/proc/self/exe", appPath, sizeof( appPath ) );
//// Catch some errors
//if ( length < 0 )
//{
// WLogger::getLogger()->addLogMessage( "Error resolving symlink /proc/self/exe.", "Kernel", LL_ERROR );
//}
//if ( length >= 255 )
//{
// WLogger::getLogger()->addLogMessage( "Path too long. Truncated.", "Kernel", LL_ERROR );
//}
//// the string this readlink() function returns is appended with a '@'.
//appPath[length] = '\0';
//// strip off the executable name
//while ( appPath[length] != '/' )
//{
// appPath[length] = '\0';
// --length;
// assert( length >= 0 );
//}
m_AppPath = appPath;
m_AppPath += "/";
m_shaderPath = m_AppPath + "shaders/";
// getcwd/get_current_dir_name() mallocs memory, free it here
delete appPath;
#elif defined( __APPLE__ )
char path[1024];
uint32_t size = sizeof( path );
if( _NSGetExecutablePath( path, &size ) == 0 )
{
WLogger::getLogger()->addLogMessage( "Executable path is " + std::string( path ), "Kernel", LL_DEBUG );
int i = strlen( path );
while( path[i] != '/' )
{
path[i] = '\0';
i--;
assert( i >= 0 );
}
WLogger::getLogger()->addLogMessage( "Application path is " + std::string( path ), "Kernel", LL_DEBUG );
m_AppPath = path;
std::string shaderPath( path );
m_shaderPath = shaderPath + "shaders/";
}
else
{
WLogger::getLogger()->addLogMessage( "Buffer too small; need size " + boost::lexical_cast< std::string >( size ),
"Kernel", LL_ERROR );
assert( size <= sizeof( path ) );
}
#else
#pragma message( "Error: findAppPath not implemented for this platform" )
// for windows, use something like this:
// DWORD GetModuleFileName( NULL, HMODULE hModule, // handle to module
// LPTSTR lpFilename, // path buffer
// DWORD nSize // size of buffer
// );
#endif
*/
}
const WBoolFlag& WKernel::isFinishRequested() const
......
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