Re: [Development] Why does Q_ENUM() need qRegisterMetaType()?

2019-07-04 Thread Tom Isaacson
> The problem is that moc only generates the code that calls qRegisterMetaType 
> if it sees Q_DECLARE_METATYPE. Actually, it does a bit more than that. It 
> could as well do it for Q_ENUM type, just not implemented yet.
>
> We should consider doing it for all the types used in 
> signals/slots/properties. 
>  But it does not do it because that could be a potential breaking change for 
> forward declared types.
> Maybe something for Qt6.

It's very confusing. You said yourself on https://woboq.com/blog/q_enum.html 
that "These enums are automatically declared as a QMetaTypes (no need to add 
them in Q_DECLARE_METATYPE anymore)." So Q_ENUM replaces Q_DECLARE_METATYPE and 
provides additional functionality but requires you to add an additional call to 
qRegisterMetaType? That seems backward.

Can I use Q_DECLARE_METATYPE and Q_ENUM and avoid qRegisterMetaType?

Tom Isaacson

___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


[Development] Why does Q_ENUM() need qRegisterMetaType()?

2019-07-03 Thread Tom Isaacson
No response on Qt Interest so trying here.

I'm using Qt 5.12.2 on Visual Studio 2019 / Win7. I wanted to make sure Q_ENUM 
works the way I think it does before updating some legacy code so I wrote a 
unit test (we use Google Test):

TestConnectEnum.h:

class tColoredObjectV3 : public QObject
{
Q_OBJECT

public:
enum class eColor
{
Red = 1,
Blue = 2,
Green = 3
};
Q_ENUM(eColor)

tColoredObjectV3() : m_color(tColoredObjectV3::eColor::Red) {}

void EmitColor(tColoredObjectV3::eColor color);

signals:
void ColorSignal(tColoredObjectV3::eColor color);

private:
eColor m_color;
};

TestEnumConnect.cpp:

TEST(Connect, ConnectEnumSucceedsV3)
{
//qRegisterMetaType();

tColoredObjectV3 coloredObject;

QSignalSpy spy(, ::ColorSignal);
coloredObject.EmitColor(tColoredObjectV3::eColor::Blue);

EXPECT_TRUE(spy.isValid());
EXPECT_EQ(spy.count(), 1); // make sure the signal was emitted exactly 
one time
QList arguments = spy.takeFirst(); // take the first signal
ASSERT_FALSE(arguments.isEmpty());
tColoredObjectV3::eColor color = 
arguments.at(0).value();
EXPECT_EQ(tColoredObjectV3::eColor::Blue, color); // verify the first 
argument }

But this fails - I have to uncomment the qRegisterMetaType() to get it to work. 
If I use the old Q_DECLARE_METATYPE() this works. Am I doing something wrong or 
does Q_ENUM() require this?

Tom Isaacson

___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Use QMetaEnum::keyCount() to initialise array

2019-01-07 Thread Tom Isaacson
I wonder if moc-ng could handle this?
https://woboq.com/blog/moc-with-clang.html

Tom Isaacson


-Original Message-
From: Development  On Behalf Of Thiago 
Macieira
Sent: Thursday, January 3, 2019 1:43 AM
To: development@qt-project.org
Subject: Re: [Development] Use QMetaEnum::keyCount() to initialise array

On Wednesday, 2 January 2019 09:45:29 -02 Thiago Macieira wrote:
> Because the information is not known to the compiler at compile time.

To be stricter: it *is* know to the compiler, but without a constexpr 
reflection API, we can't get the information out of the compiler and into code.

--
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Adding Visual Studio 2019 support

2019-01-05 Thread Tom Isaacson
I added a comment to the change but I don’t think Miguel is on Github:
https://github.com/qt-labs/vstools/commit/1759c2f7bf66e6f5cc032df6764b51d9a96f6a57#r31802818

Tom Isaacson


-Original Message-
From: Development  On Behalf Of Tom Isaacson
Sent: Sunday, December 30, 2018 8:24 AM
To: development@qt-project.org
Subject: [Development] Adding Visual Studio 2019 support

I can see that Miguel has added VS2019 support:
https://github.com/qt-labs/vstools/commit/1759c2f7bf66e6f5cc032df6764b51d9a96f6a57

but where can I get the development build for this? I can't see it in 
https://download.qt.io/development_releases/vsaddin/, is it somewhere else or 
has it just not been added yet?

Tom Isaacson
___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


[Development] Use QMetaEnum::keyCount() to initialise array

2018-12-30 Thread Tom Isaacson
Is it possible to use QMetaEnum::keyCount() to initialise an array? Something 
like:

const QMetaEnum metaEnum = QMetaEnum::fromType();
int MyArray[metaEnum.keyCount()];

After asking this on the Qt-Interest forum I spent a bit of time investigating. 
Q_ENUM declares functions with Q_DECL_CONSTEXPR:
#define Q_ENUM(ENUM) \
friend Q_DECL_CONSTEXPR const QMetaObject *qt_getEnumMetaObject(ENUM) 
Q_DECL_NOEXCEPT { return  } \
friend Q_DECL_CONSTEXPR const char *qt_getEnumName(ENUM) 
Q_DECL_NOEXCEPT { return #ENUM; }

In my example code above, QMetaEnum::fromType() calls these functions:
template static QMetaEnum fromType() {
Q_STATIC_ASSERT_X(QtPrivate::IsQEnumHelper::Value,
  "QMetaEnum::fromType only works with enums declared 
as Q_ENUM or Q_FLAG");
const QMetaObject *metaObject = qt_getEnumMetaObject(T());
const char *name = qt_getEnumName(T());
return metaObject->enumerator(metaObject->indexOfEnumerator(name));
}

Where it breaks is the last line, because QMetaObject::indexOfEnumerator() uses 
d.data:
https://github.com/qt/qtbase/blob/96efc38f100686a8183f45367e54bf6cb670bdba/src/corelib/kernel/qmetaobject.cpp#L968
int QMetaObject::indexOfEnumerator(const char *name) const
{
const QMetaObject *m = this;
while (m) {
const QMetaObjectPrivate *d = priv(m->d.data);

Which is only defined as const:
https://github.com/qt/qtbase/blob/96efc38f100686a8183f45367e54bf6cb670bdba/src/corelib/kernel/qobjectdefs.h#L578
struct { // private data
const QMetaObject *superdata;
const QByteArrayData *stringdata;
const uint *data;

I don't know how the Meta-Object Compiler creates this but surely it's possible 
to change it to be constexpr?

Tom Isaacson

___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


[Development] Adding Visual Studio 2019 support

2018-12-29 Thread Tom Isaacson
I can see that Miguel has added VS2019 support:
https://github.com/qt-labs/vstools/commit/1759c2f7bf66e6f5cc032df6764b51d9a96f6a57

but where can I get the development build for this? I can't see it in 
https://download.qt.io/development_releases/vsaddin/, is it somewhere else or 
has it just not been added yet?

Tom Isaacson


___
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Building with Qt 5.11.1 and Visual Studio 2017

2018-09-06 Thread Tom Isaacson
> You must have some stale headers or precompiled headers lying around. Make 
> sure it's a completely clean build and that the older version of Qt is not 
> anywhere to be found.

I've tried everything:
* Renamed the old Qt 5.6 directory
* Checked to see I don't have any Qt environment variables set
* Told Visual Studio to do a clean build
* Manually deleted Debug and GeneratedFiles directories
* Manually deleted C:\Users\Tom\AppData\Local\QtMsBuild directory (from 
https://blog.qt.io/blog/2018/01/24/qt-visual-studio-new-approach-based-msbuild/)
* Changed the compiler to ISO C++17 Standard (/std:c++17)

Any other suggestions?

The only thing I'm doing that's slightly unusual is building against the Visual 
Studio 2015 32-bit binaries because we haven't moved our app to 64-bit yet. But 
I wouldn't have thought this wouldn't be a problem until linking?

Tom Isaacson

1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(51): error C4430: 
missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(51): error C2146: 
syntax error: missing ';' before identifier 'QT_WARNING_PUSH'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(57): error C2143: 
syntax error: missing ';' before '{'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(57): error C2447: 
'{': missing function header (old-style formal list?)
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(317): error 
C2144: syntax error: 'void' should be preceded by ';'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(317): error 
C2065: 'ForwardIterator': undeclared identifier
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(317): error 
C2146: syntax error: missing ')' before identifier 'begin'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(318): error 
C2143: syntax error: missing ';' before '{'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(318): error 
C2447: '{': missing function header (old-style formal list?)
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(685): error 
C4430: missing type specifier - int assumed. Note: C++ does not support 
default-int
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(685): error 
C2146: syntax error: missing ';' before identifier 'Q_DECL_CONSTEXPR'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(686): error 
C2143: syntax error: missing ';' before '{'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(686): error 
C2447: '{': missing function header (old-style formal list?)
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(698): error 
C4430: missing type specifier - int assumed. Note: C++ does not support 
default-int
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(698): error 
C2086: 'int Q_DECL_CONST_FUNCTION': redefinition
(cont)

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


[Development] Building with Qt 5.11.1 and Visual Studio 2017

2018-09-05 Thread Tom Isaacson
We're currently using Qt 5.6 but looking to upgrade soon. I tried building our 
app on Qt 5.11.1 with Visual Studio 2017 V15.8.2 and it failed on the first 
file:
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(51): error C4430: 
missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(51): error C2146: 
syntax error: missing ';' before identifier 'QT_WARNING_PUSH'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(57): error C2143: 
syntax error: missing ';' before '{'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(57): error C2447: 
'{': missing function header (old-style formal list?)
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(317): error 
C2144: syntax error: 'void' should be preceded by ';'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(317): error 
C2065: 'ForwardIterator': undeclared identifier
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(317): error 
C2146: syntax error: missing ')' before identifier 'begin'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(318): error 
C2143: syntax error: missing ';' before '{'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(318): error 
C2447: '{': missing function header (old-style formal list?)
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(685): error 
C4430: missing type specifier - int assumed. Note: C++ does not support 
default-int
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(685): error 
C2146: syntax error: missing ';' before identifier 'Q_DECL_CONSTEXPR'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(686): error 
C2143: syntax error: missing ';' before '{'
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(686): error 
C2447: '{': missing function header (old-style formal list?)
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(698): error 
C4430: missing type specifier - int assumed. Note: C++ does not support 
default-int
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(698): error 
C2086: 'int Q_DECL_CONST_FUNCTION': redefinition
1>c:\qt\qt5.11.1\5.11.1\msvc2015\include\qtcore\qalgorithms.h(685): note: see 
declaration of 'Q_DECL_CONST_FUNCTION'
(cont)

I searched around and found:
https://forum.qt.io/topic/93714/visual-studio-15-8-0-and-qt-5-11-1-does-not-compile-qrandom-std-aligned_storage
but I've already done a completely clean build. It seems like there are changes 
being made here:
https://codereview.qt-project.org/#/c/236948/2/src/corelib/tools/qalgorithms.h
so should I wait for Qt5.11.2?

Tom Isaacson

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


[Development] QMovie no longer supports .mng

2016-04-24 Thread Tom Isaacson
I've just upgraded from Qt 5.5.1 to 5.6 using Visual Studio 2013 for 32-bit on 
Windows 7 and I've found that QMovie fails to load .mng files. Calling 
QMovie::supportedFormats() just returns "gif". Previously this was working fine.

Is this an intentional change? How can I get round it?

Thanks,

Tom Isaacson

___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] MSVC2015 and Qt5.5 -- dot release plans?

2015-07-23 Thread Tom Isaacson
 I don't know whether we'll be able to produce binaries for it for 5.5.1. That 
 depends on how soon we can bring it up in the old CI.

Any idea when 5.5.1 is due now? The Wiki says the original date was September 
but will this be pushed out?
https://wiki.qt.io/Qt-5.5-release

Tom Isaacson



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Relevant industrial buses

2015-07-10 Thread Tom Isaacson
There are a lot more commands in NMEA2000 than just position. As far as I can 
see QNmeaPositionInfoSource just allows you to enter data you've already 
parsed, there's no bus support there.

Tom Isaacson

-Original Message-
From: Blasche Alexander [mailto:alexander.blas...@theqtcompany.com] 
Sent: Saturday, 11 July 2015 1:34 a.m.
To: Tom Isaacson; development@qt-project.org
Subject: RE: [Development] Relevant industrial buses


 -Original Message-
 From: development-bounces+alexander.blasche=theqtcompany.com@qt-
 project.org [mailto:development-
 bounces+alexander.blasche=theqtcompany@qt-project.org] On Behalf Of
 Tom Isaacson
 Sent: Friday, 10 July 2015 11:13
 To: development@qt-project.org
 Subject: Re: [Development] Relevant industrial buses
 
 Not sure this counts as industrial but NMEA2000 for marine would be good.

http://doc.qt.io/qt-5/qnmeapositioninfosource.html

Even if this is not sufficient, I would not put it into the category of 
industrial buses.

--
Alex



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] FTP in Qt5

2014-03-08 Thread Tom Isaacson
 There are no plans. FTP is really low-priority these days.

Well we're still using it. Plus I said resume functionality for HTTP and FTP - 
I still think resume is an important part of any downloader so you don't end up 
having to download the same data. Is there no interest in this?

Tom



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


[Development] FTP in Qt5

2014-03-07 Thread Tom Isaacson
I needed this functionality in our application so I've written a demo app to 
handle pausing and resuming HTTP and FTP downloads:
https://github.com/parsley72/QtDownloadManager

We use Qt 4.8.2 so the FTP download is implemented with QFtp. We're intending 
to migrate to Qt5 later this year but since QFtp is deprecated in Qt5 this 
functionality isn't possible. I can't see any issue for this - the closest are:
https://bugreports.qt-project.org/browse/QTBUG-32819 Comment 
QNetworkAccessManager doesn't have the features for a full FTP client but no 
suggestion of when this might be improved.
https://bugreports.qt-project.org/browse/QTBUG-8491 Comments about adding other 
network protocols to QNetworkAccessManager.

Is there any plan to extend QNetworkAccessManager so it can handle resumes for 
FTP, or any alternative?

Thanks,

Tom



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] FTP in Qt5

2014-03-07 Thread Tom Isaacson
 Is https://qt.gitorious.org/qt/qtftp/source/readme.txt an option?
Yes. I've just recently added it to one of my projects for QFtp / QUrlInfo 
compatibility in Qt 5.

I thought it was odd that functionality from Qt4 was removed with no intention 
to replace it. I was also surprised at how much fiddling around I had to do to 
get the resume functionality to work in both HTTP and FTP. I was wondering if 
there was a plan to add the resume functionality to QNetworkAccessManager so 
this would work for both HTTP and FTP but it seems not.

The code I've published works but I have no idea how you could go about 
arranging this into an API for QNetworkAccessManager. There are some comments 
about reorganising the code in 
https://bugreports.qt-project.org/browse/QTBUG-8491 - does anyone know if 
there's a plan for this yet?

Tom



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Visual Studio 2013 support

2014-01-03 Thread Tom Isaacson
Who's in charge of the Visual Studio add-in installer?

Tom

-Original Message-
From: development-bounces+tom.isaacson=navico@qt-project.org 
[mailto:development-bounces+tom.isaacson=navico@qt-project.org] On Behalf 
Of Tom Isaacson
Sent: Wednesday, 1 January 2014 10:42 a.m.
To: Development@qt-project.org
Subject: [Development] Visual Studio 2013 support

Is there any plan yet to add Visual Studio 2013 support to the Qt add-in? I was 
wondering if the installer needed to be rewritten because I found this article 
suggesting that add-ins had been deprecated:
http://msdn.microsoft.com/en-us/library/5abkeks7.aspx

What I'm wondering is if this means the new VSPackage will work in Visual 
Studio 2013 Express?

Tom



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


[Development] Visual Studio 2013 support

2013-12-31 Thread Tom Isaacson
Is there any plan yet to add Visual Studio 2013 support to the Qt add-in? I was 
wondering if the installer needed to be rewritten because I found this article 
suggesting that add-ins had been deprecated:
http://msdn.microsoft.com/en-us/library/5abkeks7.aspx

What I'm wondering is if this means the new VSPackage will work in Visual 
Studio 2013 Express?

Tom



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


[Development] Extending Visual Studio's display of Qt classes

2012-09-16 Thread Tom Isaacson
I've been working on some networking code recently and I got very frustrated 
with not being able to see the IP and MAC addresses in QHostAddress and 
QNetworkInterface whilst debugging in Visual Studio. After a bit of 
experimentation I was able to add viewers for these classes to autoexp.dat and 
I've posted these below. But the problem I had is that these classes follow the 
Pimpl Idiom, so it's impossible for Visual Studio to be able to see the members 
of the classes in order to display the values. I had to look into the 
implementation of the private part of the classes then use byte shuffling in 
autoexp.dat to display them. This means that if the layout of the classes ever 
changes this method will display the wrong data, which is why I'm not sure if 
it's a good idea to add this to the Visual Studio Add-In installer. However, if 
anyone wants to do this then go ahead.

I understand why the Pimpl Idiom is being used here, but I'm wondering if it's 
actually necessary. It's intended for when the source code of the 
implementation isn't available so internal variables and function names can be 
completely hidden. But in the case of Qt, where the source code is available 
and can even be used to build your own binaries, it seems excessive. It also 
means that useful displays of debugging data aren't really possible and you 
have to resort to what I've done below.

Can I suggest that going forward the Pimpl Idiom is dropped and we go back to 
just using private member variables and functions to prevent them being called 
from outside the class? Or is there some alternative that would allow VS to see 
the layout it needs?

QHostAddress|*::QHostAddress{
preview
(
#(
#if (*((quint32 *)$e.d.d) != 0) (
#(IPv4=, [*(((quint8 *)$e.d.d) + 3), u],
., [*(((quint8 *)$e.d.d) + 2), u],
., [*(((quint8 *)$e.d.d) + 1), u],
., [*(((quint8 *)$e.d.d) + 0), u])
) #elif ((*(((quint32 *)$e.d.d) + 1)) + (*(((quint32 *)$e.d.d) + 
2)) + (*(((quint32 *)$e.d.d) + 3)) + (*(((quint32 *)$e.d.d) + 4)) != 0) (
#(IPv6=,
[(quint16)((*(((quint8 *)$e.d.d) + 0x04)  0x8) | (*(((quint8 
*)$e.d.d) + 0x05))), x],
.,
[(quint16)((*(((quint8 *)$e.d.d) + 0x06)  0x8) | (*(((quint8 
*)$e.d.d) + 0x07))), x],
.,
[(quint16)((*(((quint8 *)$e.d.d) + 0x08)  0x8) | (*(((quint8 
*)$e.d.d) + 0x09))), x],
.,
[(quint16)((*(((quint8 *)$e.d.d) + 0x0A)  0x8) | (*(((quint8 
*)$e.d.d) + 0x0B))), x],
.,
[(quint16)((*(((quint8 *)$e.d.d) + 0x0C)  0x8) | (*(((quint8 
*)$e.d.d) + 0x0D))), x],
.,
[(quint16)((*(((quint8 *)$e.d.d) + 0x0E)  0x8) | (*(((quint8 
*)$e.d.d) + 0x0F))), x],
.,
[(quint16)((*(((quint8 *)$e.d.d) + 0x10)  0x8) | (*(((quint8 
*)$e.d.d) + 0x11))), x],
.,
[(quint16)((*(((quint8 *)$e.d.d) + 0x12)  0x8) | (*(((quint8 
*)$e.d.d) + 0x13))), x])
)
)
)
children
(
#(
[d]: [$c.d.d, x]
)
)
}


 
QNetworkInterface|*::QNetworkInterface{
preview
(
#(
[(QString *)(((quint32 *)$e.d.d) + 0x4)]
)
)
children
(
#(
[d]: [$c.d.d, x],
[QSharedData]: [*(((quint32 *)$c.d.d) + 0x0), u],
[index]: [*(((quint32 *)$c.d.d) + 0x1), u],
[flags.i]: [*(((quint32 *)$c.d.d) + 0x2), u],
[name]: [(QString *)(((quint32 *)$c.d.d) + 0x3)],
[friendlyName]: [(QString *)(((quint32 *)$c.d.d) + 0x4)],
[hardwareAddress]: [(QString *)(((quint32 *)$c.d.d) + 0x5)]
)
)
}

TOM ISAACSON | SENIOR SOFTWARE DEVELOPER | NAVICO ASIA PACIFIC



___
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development


Re: [Development] Extending Visual Studio's display of Qt classes

2012-09-16 Thread Tom Isaacson
 I'm not especially familiar with debugging in VS, but I would have thought 
 that in a debug build, VS has enough information about the data types of the 
 pimpl classes to display them in the debugger.

Only if you build from the source. If you install the prebuilt libraries then 
it has no idea what the private class implementation is because it doesn't have 
the header files.

TOM ISAACSON | SENIOR SOFTWARE DEVELOPER | NAVICO ASIA PACIFIC



-Original Message-
From: Robert Knight [mailto:robertkni...@gmail.com] 
Sent: Sunday, 16 September 2012 10:57 p.m.
To: Tom Isaacson
Cc: development@qt-project.org
Subject: Re: [Development] Extending Visual Studio's display of Qt classes

  It's intended for when the source code of the implementation isn't available 
 so internal variables and function names can be completely hidden.

That is not the motivation at all in Qt's case.  The reasons for it are:

- Binary compatibility between minor Qt versions.  Adding, removing or changing 
fields in the pimpl class does not alter the layout or size of the public class.
- It permits sharing of data between instances of the public class (aka. copy 
on write.  See QSharedData).
- During development, the amount of code that is recompiled when changing 
private implementation details in the pimpl class is reduced.

I'm not especially familiar with debugging in VS, but I would have thought that 
in a debug build, VS has enough information about the data types of the pimpl 
classes to display them in the debugger.

Regards,
Rob.

On 16 September 2012 11:08, Tom Isaacson tom.isaac...@navico.com wrote:
 I've been working on some networking code recently and I got very frustrated 
 with not being able to see the IP and MAC addresses in QHostAddress and 
 QNetworkInterface whilst debugging in Visual Studio. After a bit of 
 experimentation I was able to add viewers for these classes to autoexp.dat 
 and I've posted these below. But the problem I had is that these classes 
 follow the Pimpl Idiom, so it's impossible for Visual Studio to be able to 
 see the members of the classes in order to display the values. I had to look 
 into the implementation of the private part of the classes then use byte 
 shuffling in autoexp.dat to display them. This means that if the layout of 
 the classes ever changes this method will display the wrong data, which is 
 why I'm not sure if it's a good idea to add this to the Visual Studio Add-In 
 installer. However, if anyone wants to do this then go ahead.

 I understand why the Pimpl Idiom is being used here, but I'm wondering if 
 it's actually necessary. It's intended for when the source code of the 
 implementation isn't available so internal variables and function names can 
 be completely hidden. But in the case of Qt, where the source code is 
 available and can even be used to build your own binaries, it seems 
 excessive. It also means that useful displays of debugging data aren't really 
 possible and you have to resort to what I've done below.

 Can I suggest that going forward the Pimpl Idiom is dropped and we go back to 
 just using private member variables and functions to prevent them being 
 called from outside the class? Or is there some alternative that would allow 
 VS to see the layout it needs?

 QHostAddress|*::QHostAddress{
 preview
 (
 #(
 #if (*((quint32 *)$e.d.d) != 0) (
 #(IPv4=, [*(((quint8 *)$e.d.d) + 3), u],
 ., [*(((quint8 *)$e.d.d) + 2), u],
 ., [*(((quint8 *)$e.d.d) + 1), u],
 ., [*(((quint8 *)$e.d.d) + 0), u])
 ) #elif ((*(((quint32 *)$e.d.d) + 1)) + (*(((quint32 *)$e.d.d) + 
 2)) + (*(((quint32 *)$e.d.d) + 3)) + (*(((quint32 *)$e.d.d) + 4)) != 0) (
 #(IPv6=,
 [(quint16)((*(((quint8 *)$e.d.d) + 0x04)  0x8) | 
 (*(((quint8 *)$e.d.d) + 0x05))), x],
 .,
 [(quint16)((*(((quint8 *)$e.d.d) + 0x06)  0x8) | 
 (*(((quint8 *)$e.d.d) + 0x07))), x],
 .,
 [(quint16)((*(((quint8 *)$e.d.d) + 0x08)  0x8) | 
 (*(((quint8 *)$e.d.d) + 0x09))), x],
 .,
 [(quint16)((*(((quint8 *)$e.d.d) + 0x0A)  0x8) | 
 (*(((quint8 *)$e.d.d) + 0x0B))), x],
 .,
 [(quint16)((*(((quint8 *)$e.d.d) + 0x0C)  0x8) | 
 (*(((quint8 *)$e.d.d) + 0x0D))), x],
 .,
 [(quint16)((*(((quint8 *)$e.d.d) + 0x0E)  0x8) | 
 (*(((quint8 *)$e.d.d) + 0x0F))), x],
 .,
 [(quint16)((*(((quint8 *)$e.d.d) + 0x10)  0x8) | 
 (*(((quint8 *)$e.d.d) + 0x11))), x],
 .,
 [(quint16)((*(((quint8 *)$e.d.d) + 0x12)  0x8) | 
 (*(((quint8 *)$e.d.d) + 0x13))), x])
 )
 )
 )
 children
 (
 #(
 [d]: [$c.d.d, x]
 )
 )
 }



 QNetworkInterface|*::QNetworkInterface{
 preview
 (
 #(
 [(QString