Forum

Results 1 to 13 of 13
  1. #1
    Join Date
    December 2009
    Location
    Germany
    Posts
    32

    creating widget in ts3client_configure(handler)

    Hi, i tried to create a qt widget in the configure function, but i keep getting the error

    Code:
    QPixmap: It is not safe to use pixmaps outside the GUI thread
    and the program crashes most of the time, because obviously the function is called by a thread that is not the main thread, any ideas? i tried it with the qt versions 4.5.3 and 4.6.0 an im developing in ubuntu 9.10

    the code looks something like

    Code:
    void ts3plugin_configure(void* handle) {
        ConfigureWidget* w = new ConfigureWidget(NULL);
        w->show();
    }

    by the way, it is still not very clear what we could use the handle for

  2. #2
    Join Date
    April 2009
    Location
    Germany / Deutschland
    Posts
    71
    I would try using http://qt.nokia.com/doc/4.6/qwidget.html#QWidget with the parent set to void* handle. But i never used QT so its just an idea.

  3. #3
    Join Date
    December 2009
    Location
    Germany
    Posts
    32
    I think you meant something like

    void ts3plugin_configure(void* handle) {
    QWidget* w = new QWidget((QWidget*)handle);
    w->show();
    }

    but unfortunately this also gives the same errors. ConfigurationWidget inherits QWidget and thus should work instead of QWidget because its the normal way to cstomize widgets in qt.

    I recognised, that using

    void ts3plugin_configure(void* handle) {
    QWidget* w = new QWidget(NULL);
    w->show();
    }
    in fact DOES work. but hey thats just totally ugly, i dont want to add all the stuff to the window manually in a c function. my ConfigurationWidget does nothing but inherit from QWidget, s it also should work with that, maybe i need to do do more debug on that
    Last edited by banane; December 28th, 2009 at 12:40 PM.

  4. #4
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    Do you use the same Qt version and the same compiler on your platform?

    Check, if the qApp pointer is set in your library. All UI classes in Qt need a QApplication object.
    If you are using the same versions, you can use the eventloop of the client.

  5. #5
    Join Date
    December 2009
    Location
    Germany
    Posts
    32
    is use the same versions for dev and qt (4.5.3really4.5.2-0ubuntu1)

    i checked the address of qapp and its definitely not null and i can access the application name and stuff

    even if i dont do anything at all in the configure function, i get a

    Code:
    QThread: Destroyed while thread is still running
    Segmentation fault
    And thats even more strange, i reproduced this behaviour with the test plugin just changing the returnvalue of offersConfigure() to 1, which also segfaults on configure().

    Sometimes i also get some Errors about locks and unlocks, what makes me think, that we maybe have to lock on some mutex before doing anything in the configure(), buts thats just guessing.

    i mean it should at least run if there is no code in the configure function i thought.

    @Thomas, can you explain how exactly you mean
    If you are using the same versions, you can use the eventloop of the client.
    would be also cool if someone could post a minimum working example with a widget opening in the configure function
    Last edited by banane; December 29th, 2009 at 12:56 AM.

  6. #6
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    @Thomas, can you explain how exactly you mean
    I meant, that if the qApp pointer is set, you can use the same eventloop, the client created and uses.

  7. #7
    Join Date
    December 2009
    Location
    Germany
    Posts
    32
    mh, i cant see how the eventloop may help me creating a window, as i understood, the eventloop ist the main loop of the program processing events, okay, but how to hook myself into there?

    cant someone point me to a working example?

  8. #8
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    If the qApp pointer is set, you can create Qt ui classes.
    I think we talked at cross purposes.

    Perhaps it will help, if you copy the Qt libraries (QtCore4 and QtGui4 in the installation folder to the plugin path (in some of my tests with some Qt classes in a plugin, this did the trick).

  9. #9
    Join Date
    December 2009
    Location
    Germany
    Posts
    32
    thank you thomas, you are very responsive even at late night

    copying the libraries helped so i can now create and show a widget. i can even create and show my own widget, although i get following errors, the program doesnt crash anymore

    Code:
    QThread: Destroyed while thread is still running
    QWaitCondition::wakeAll(): mutex lock failure:
    QWaitCondition::wakeAll(): mutex unlock failure:
    but as soon as i set an own layout in the widget, the ugly errors occur again saying that its not safe to use pixmaps outside the main loop and crashes the program

    in fact i can create an instance of my widget for example in the ts3plugin_init() routine without any problems, it works well as long as i create and show it there, but then the window will be visible as long as the plugin is active, thats maybe an emergency solution to me, but thats still not the way it should work

    everything looks like the configure routine is somehow called in a different thread than the gui thread

  10. #10
    Join Date
    September 2005
    Location
    Germany / Dortmund
    Posts
    1,376
    I remember, I had the same problems in my first tests with the Plugin SDK in the alpha phase. But I can't remember my solution, but I will search in my test plugins (in a few hours, when I wake up ).

    Did you link against the debug or release libs?

  11. #11
    Join Date
    December 2009
    Location
    Germany
    Posts
    32
    i tried debug and release, doesnt change anything

  12. #12
    Join Date
    December 2009
    Location
    Germany
    Posts
    32
    if someone has got a config window working, then please post the code including projectfiles, so i can at least find out wether the crashes depend on my build system or on wrong code!

  13. #13
    Join Date
    December 2009
    Location
    Germany
    Posts
    32
    i still want to get this working, cant anybody help?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Request] Widget w/PTT
    By ThreeFootSmurf in forum Android
    Replies: 3
    Last Post: February 28th, 2014, 09:29 PM
  2. Guildzilla TS3 Widget Help
    By polo53 in forum Windows
    Replies: 3
    Last Post: June 16th, 2012, 08:56 PM
  3. Help setting up widget
    By Gardanis in forum Tools / Web Based
    Replies: 1
    Last Post: January 29th, 2012, 11:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •