Results 1 to 5 of 5

Thread: Heelppp please !

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2007
    Posts
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Heelppp please !

    This is my problem, i have created custom widgets which i put them on a library ( PulzarLib)
    when i use the widgets as members of a class in my program everything is ok.. but if i INHERIT my custom widget ( from the library PulzarLib) my program crashes

    PD: Sorry my bad english !

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Heelppp please !

    Please, try to use more descriptive thread titles. Could you provide an example that reproduces the problem?
    J-P Nurmi

  3. #3
    Join Date
    Jul 2007
    Posts
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Heelppp please !

    Quote Originally Posted by jpn View Post
    Please, try to use more descriptive thread titles. Could you provide an example that reproduces the problem?
    Thanks for answering, here is my problem : i have made an application that is composed of libraries, the application itself and a set of modules implemented as plugins:

    This is the structure of my applcation :

    - PulzarApp ( the application itself )
    - PulzarLib ( Core libraried)
    - PulzarMod (Modules, implemented as plugins)
    - PulzarQtPluguins ( Pluguins for Qt designer, custom widgets )
    - PulzarRps ( Reports, implemented as plugins )
    - Pulzar Rpt ( Report engine, library )
    - PulzarXml ( The reports definitions )

    So far so good, my application runs flawless in linux, but when i compilie in windows i had some trouble :

    First Problem : My application crashes once compiled, i start to trace the problem and noticed the one of the classes in PulzarApp inherits from a class of PulzarLib , so just for test, i removed that dependency and reimplemented the PulzarApp class without any inheritance from PulzarLib and made instances of PulzarLib classes to keep the functionality ... that worked. But the "solution" came when i compiled PulzarLib as a static lib... i dont know why, and its far better to have that library as shared ( dll )

    Second problem :
    I have a class MainWindow ( which is my applications Main Window itself ) in PulzarApp which inherits MainWindowGui from PulzarLib, i need to have a pointer to the MainWindow so components can communicate with others , i tried to implement this using a static member of MainWindowGui :

    MainWindowGui.h :

    {
    QOBJECT
    ......
    private :
    static MainWindowGui* self;
    .....
    }

    MainWindowGui.cpp

    MainWindowGui* MainWindowGui::self = 0;

    MainWindowGui::MainWindowGui( ...)
    {
    MainWindowGui::self = this;
    }

    but when i call this pointer later it always retunr 0, crashing my application ( again in linux this wasnt a problem )

    thank you very much for your help

  4. #4
    Join Date
    Aug 2006
    Posts
    44
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Heelppp please !

    It's hard to offer more detailed help without more specific code, or a more detailed 'pseudo-code' description of your application.

    I'm guessing, but it sounds like you've got some globals and / or static data that act as your fundamental data structures. This generally leads to odd problems such as what you're describing, because different compilers can generate the initialization code for globals and statics in slightly different ways. This is even more likely when you move from one platform to another. I've had this kind of problem happen to me before. The solution is to use explicit initialization / cleanup functions to guarantee that you know when objects are properly created / destroyed, and NOT rely on the behavior of a specific compiler.

    For example, what is the first code that accesses MainWindowGui::self? If it's not the constructor of MainWindowGui, then MainWindowGui::self will be NULL.

    When does your code create MainWindowGui? If you have a global variable that access MainWindowGui::self before you've called the MainWindowGui constructor explicitly, there's no way MainWindowGui::self can be properly initialized.

    Also, I foresee that you may run into some fun problems using your library in other Qt programs. These problems stem from the requirement that there be only one QApplication. If your code always creates a QApplication, then you'll have some trouble if someone else has a program that creates a QApplication and then loads and uses your library. You can work around some of those problems by checking for an application instance and creating it if you need to.

    Hope something in this helps! ;-)

  5. #5
    Join Date
    Jul 2007
    Posts
    17
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Angry Re: Heelppp please !

    Quote Originally Posted by Eldritch View Post
    It's hard to offer more detailed help without more specific code, or a more detailed 'pseudo-code' description of your application.

    I'm guessing, but it sounds like you've got some globals and / or static data that act as your fundamental data structures. This generally leads to odd problems such as what you're describing, because different compilers can generate the initialization code for globals and statics in slightly different ways. This is even more likely when you move from one platform to another. I've had this kind of problem happen to me before. The solution is to use explicit initialization / cleanup functions to guarantee that you know when objects are properly created / destroyed, and NOT rely on the behavior of a specific compiler.

    For example, what is the first code that accesses MainWindowGui::self? If it's not the constructor of MainWindowGui, then MainWindowGui::self will be NULL.

    When does your code create MainWindowGui? If you have a global variable that access MainWindowGui::self before you've called the MainWindowGui constructor explicitly, there's no way MainWindowGui::self can be properly initialized.

    Also, I foresee that you may run into some fun problems using your library in other Qt programs. These problems stem from the requirement that there be only one QApplication. If your code always creates a QApplication, then you'll have some trouble if someone else has a program that creates a QApplication and then loads and uses your library. You can work around some of those problems by checking for an application instance and creating it if you need to.

    Hope something in this helps! ;-)

    Thank you very much for answering. I have solved my problems and you were right !
    for any one interested :

    Resolution Problem 1 : Symbols must be exported explicitly in Windows ( shitdows for now on ) when building a shared library. check this thread : http://www.qtcentre.org/forum/f-qt-p...tion-6474.html

    i havent sleep for 2 nights investigating this problem , first time i encounter a very technical problem to hate windows very veeery much

    Resolution Problem 2 : i have fallen in the "static initialization order fiasco" trap. check this page : http://www.parashift.com/c++-faq-lit...html#faq-10.15

    thank you for answering again eldritch

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.