Interpreting Q_global_static (qfontdatabaseprivate, Privatedb)

Source: Internet
Author: User

According to Src/corelib/global.h
Template <typename t>
Class Qglobalstatic
{
Public
T *pointer;
Inline qglobalstatic (T *p): pointer (p) {}
Inline ~qglobalstatic () {pointer = 0;}
};

#define Q_global_static (TYPE, NAME) \
Static TYPE *name () \
{ \
static TYPE this_# #NAME; \
Static Qglobalstatic<type > global_# #NAME (&this_# #NAME); \
return global_# #NAME. Pointer; \
}

The above expands into
Static Qfontdatabaseprivate *privatedb ()
{
Static Qfontdatabaseprivate This_privatedb; Note that the first reference starts with initialization and is no longer generated
Static qglobalstatic<qfontdatabaseprivate> Global_privatedb (&this_privatedb); A pointer to the resulting object is wrapped, as above, only the first time it is generated

return global_privatedb;
}
Qfontdatabase's constructor calls CreateDatabase (which calls the Initializedb), Initializedb calls Privatedb (), and one is the first call, The Qfontdatabaseprivate object is generated

The Qdatastream *stream member in Qfontdatabaseprivate is the font that really handles Qte.

http://zhgw01.blog.163.com/blog/static/1041481220105253491586/

Interpreting Q_global_static (qfontdatabaseprivate, Privatedb)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.