QBasicAtomicPointer usage example



  • Is there any example code of QBasicAtomicPointer usage --- Thanks in advance


  • Lifetime Qt Champion

    Hi,

    AFAIK QBasicAtomicPointer is an internal class and should not be used.

    If you need something like that you should use QAtomicPointer



  • Thanks .I made changes as suggested by you:
    @
    #if QT_VERSION < QT_VERSION_CHECK(4, 4, 0)
    #define LOG4QT_DECLARE_STATIC_LOGGER(FUNCTION, CLASS)
    static Log4Qt::Logger *FUNCTION()
    {
    static Log4Qt::Logger *p_logger = 0;
    if (!p_logger)
    {
    q_atomic_test_and_set_ptr(
    &p_logger,
    0,
    Log4Qt::Logger::logger( #CLASS ));
    }
    return p_logger;
    }
    #else
    #define LOG4QT_DECLARE_STATIC_LOGGER(FUNCTION, CLASS) \

    #define LOG4QT_DECLARE_STATIC_LOGGER(FUNCTION, CLASS)                     \
        static Log4Qt::Logger *FUNCTION()                                     \
        {                                                                     \
            static QAtomicPointer<Log4Qt::Logger> p_logger ;            \
       //         Q_ATOMIC_INITIALIZER(0);                                 \
                                                                               \
            if (!p_logger.testAndSetOrdered(0,                                 \
                    Log4Qt::Logger::logger( #CLASS )))                        \
            {                                                                 \
                p_logger.testAndSetOrdered(0,                                 \
                Log4Qt::Logger::logger( #CLASS ));                            \
            }                                                                 \
            return p_logger;                                                  \
    }
    

    #endif
    @

    seems this error is removed , others error pops up , looking at them.
    Thanks much.


  • Lifetime Qt Champion

    You should first check if the current version of Log4Qt has been validated against Qt 5



  • nope, its not , but we used it , so we plan to update it to make compatible with qt5



  • also , using QAtomicPointer is not solving , still has type casting issue. Struggling with that.



  • Does
    @
    return (Log4Qt::Logger*) p_logger;
    @

    work?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.