[vlc-devel] [PATCH 03/27] qt: register QmlMainContext* as a meta-type

Fatih Uzunoğlu fuzun54 at outlook.com
Fri Dec 4 13:20:21 CET 2020


Purposefully QmlMainContext* is registered as a property instead of 
QmlMainContext. Qt expects "QmlMainContext*" to be registered. Frankly, 
I first tried to go with registering QmlMainContext directly to see if 
it'd work out but it did not work.

What is more interesting is, this patch is useless most of the time 
because I think it is already registered without explicit 
qRegisterMetaType. However, while I was doing some experiments I noticed 
that the menu did not work and I got the classic "QmlMainContext*" is 
not registered debug message when I clicked the menu button. With this 
patch it is ensured that it'll work. But I don't know what caused for it 
to be registered fail and under what circumstances there is need for an 
explicit registration.

On 04/12/2020 12:15, Pierre Lamot wrote:
> On 2020-12-04 00:01, Fatih Uzunoglu wrote:
>> in some cases qml fails to access QmlMainContext* property when it is
>> not registered as a meta-type.
>> ---
>>  modules/gui/qt/maininterface/mainui.cpp | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/modules/gui/qt/maininterface/mainui.cpp
>> b/modules/gui/qt/maininterface/mainui.cpp
>> index 41a78da1be..9cfd98cfa7 100644
>> --- a/modules/gui/qt/maininterface/mainui.cpp
>> +++ b/modules/gui/qt/maininterface/mainui.cpp
>> @@ -222,6 +222,7 @@ void MainUI::registerQMLTypes()
>>
>>      qmlRegisterType<PlayerControlBarModel>( "org.videolan.vlc", 0, 1,
>> "PlayerControlBarModel");
>>
>> +    qRegisterMetaType<QmlMainContext*>();
>
> Is there a reason you register the type with a * ?
>
>>      qmlRegisterType<QmlGlobalMenu>( "org.videolan.vlc", 0, 1,
>> "QmlGlobalMenu" );
>>      qmlRegisterType<QmlMenuBar>( "org.videolan.vlc", 0, 1, 
>> "QmlMenuBar" );
>>      qmlRegisterType<NetworkMediaContextMenu>( "org.videolan.vlc", 0,
>> 1, "NetworkMediaContextMenu" );

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4490 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20201204/62fb9cc5/attachment.bin>


More information about the vlc-devel mailing list