diff --git a/repos/libports/include/qt5/genode/thread_qt.h b/repos/libports/include/qt5/genode/thread_qt.h
index e4dd56ad1..82cdff031 100644
--- a/repos/libports/include/qt5/genode/thread_qt.h
+++ b/repos/libports/include/qt5/genode/thread_qt.h
@@ -1,5 +1,5 @@
/*
- * \brief Thread with configurable stack size
+ * \brief Thread with preconfigured stack size
* \author Christian Prochaska
* \date 2008-06-11
*/
@@ -14,102 +14,18 @@
#ifndef _INCLUDE__BASE__THREAD_QT_H_
#define _INCLUDE__BASE__THREAD_QT_H_
-#include
-#include
#include
enum { DEFAULT_STACK_SIZE = 4096*100 };
namespace Genode {
- struct Thread_entry
+ class Thread_qt : public Thread
{
- virtual void entry() = 0;
- };
-
-
- class Thread_qt : public Thread_entry
- {
- private:
-
- class Genode_thread : Thread_base
- {
- private:
-
- Thread_entry *_thread_entry;
-
- /**
- * Thread_base interface
- */
- void entry() { _thread_entry->entry(); }
-
- public:
-
- Genode_thread(const char *name,
- size_t stack_size,
- Thread_entry *thread_entry)
- :
- Thread_base(name, stack_size),
- _thread_entry(thread_entry)
- {
- /* start Genode thread */
- start();
- }
- };
-
- protected:
-
- const char *_name;
- unsigned int _stack_size;
- Genode_thread *_thread;
-
public:
- /**
- * Constructor
- *
- * \param name Thread name (for debugging)
- */
explicit Thread_qt(const char *name = "Qt ")
- :
- _name(name),
- _stack_size(DEFAULT_STACK_SIZE),
- _thread(0) { }
-
- ~Thread_qt()
- {
- if (_thread)
- destroy(env()->heap(), _thread);
- }
-
- /**
- * Set the thread's stack size - don't call when the thread is running!
- */
- bool set_stack_size(unsigned int stack_size)
- {
- /* error, if thread is already running */
- if (_thread)
- return false;
-
- _stack_size = stack_size;
- return true;
- }
-
- /**
- * Start execution of the thread
- */
- void start()
- {
- /* prevent double calls of 'start' */
- if (_thread) return;
-
- _thread = new (env()->heap()) Genode_thread(_name, _stack_size, this);
- }
-
- static Thread_base *myself()
- {
- return Thread_base::myself();
- }
+ : Thread(name) { }
};
}
diff --git a/repos/libports/src/lib/qt5/qt_main.cc b/repos/libports/src/lib/qt5/qt_main.cc
index 7f81bceee..5cdbe3ca8 100644
--- a/repos/libports/src/lib/qt5/qt_main.cc
+++ b/repos/libports/src/lib/qt5/qt_main.cc
@@ -13,65 +13,19 @@
#ifdef QT_MAIN_STACK_SIZE
-#include
-#include
-#include
-
-#include
+#include
using namespace Genode;
extern int qt_main(int argc, char *argv[]);
-class Main_thread : public Thread_qt
-{
- protected:
-
- int _argc;
- char **_argv;
- Semaphore &_finished;
- int _result;
-
- public:
-
- Main_thread(int argc, char *argv[], Semaphore &finished) :
- Thread_qt("Qt main thread"),
- _argc(argc),
- _argv(argv),
- _finished(finished),
- _result(0) { }
-
- virtual void entry()
- {
- /* call the real main() function */
- _result = ::qt_main(_argc, _argv);
-
- _finished.up();
-
- sleep_forever();
- }
-
- int result() { return _result; }
-};
-
#define qt_main main
int main(int argc, char *argv[])
{
-// PDBG("QT_MAIN_STACK_SIZE == %d", QT_MAIN_STACK_SIZE);
+ Genode::Thread_base::myself()->stack_size(QT_MAIN_STACK_SIZE);
- Semaphore finished;
-
- Main_thread main_thread(argc, argv, finished);
- main_thread.set_stack_size(QT_MAIN_STACK_SIZE);
- main_thread.start();
-
- /* wait for the thread to finish */
- finished.down();
-
-// PDBG("main_thread finished");
-
- return main_thread.result();
+ return qt_main(argc, argv);
}
#endif /* QT_MAIN_STACK_SIZE */
diff --git a/repos/libports/src/lib/qt5/qtbase/src/corelib/thread/qthread_genode.cpp b/repos/libports/src/lib/qt5/qtbase/src/corelib/thread/qthread_genode.cpp
index f9b67b915..ee59922d1 100644
--- a/repos/libports/src/lib/qt5/qtbase/src/corelib/thread/qthread_genode.cpp
+++ b/repos/libports/src/lib/qt5/qtbase/src/corelib/thread/qthread_genode.cpp
@@ -639,8 +639,10 @@ void QThread::start(Priority priority)
if (d->genode_thread) {
if (d->stackSize > 0) {
- if (!d->genode_thread->set_stack_size(d->stackSize)) {
- qWarning("QThread::start: Thread stack size error");
+ try {
+ d->genode_thread->stack_size(d->stackSize);
+ } catch (...) {
+ qWarning("QThread::start: Thread stack allocation error");
// we failed to set the stacksize, and as the documentation states,
// the thread will fail to run...