Compare commits

..
2 Commits
Author SHA1 Message Date
yyc12345 3b81c928e4 fix: include <objbase.h> before <exdisp.h> for MSVC
<exdisp.h> is not self-contained: its forward declarations use the
\interface\ macro, which is only defined in <combaseapi.h> via the
<objbase.h> include chain. Qt headers do not provide <windows.h>, so
including <exdisp.h> first caused C2146/C2371 parse errors on MSVC and
broke all IShellWindows usages. Include <objbase.h> as a prelude.
2026-10-12 16:49:56 +08:00
yyc12345 119d58a917 fix: add braces around switch-case blocks with initialized declarations
MSVC rejects declarations with initializers directly under a case label
(C2360/C2361: initialization skipped by case/default labels), while
GCC/Clang accept them. Wrap the declaring case bodies in braces.
2026-10-12 16:49:26 +08:00
2 changed files with 13 additions and 2 deletions

No files matched your search

+4 -2
View File
@@ -35,16 +35,18 @@ static const QColor& ColorSchemaToTextForeground(Qt::ColorScheme colorScheme) {
#endif // defined(Q_OS_WIN) #endif // defined(Q_OS_WIN)
switch (colorScheme) { switch (colorScheme) {
case Qt::ColorScheme::Dark: case Qt::ColorScheme::Dark: {
static QColor WHITE = QColor("White"); static QColor WHITE = QColor("White");
return WHITE; return WHITE;
}
case Qt::ColorScheme::Light: case Qt::ColorScheme::Light:
case Qt::ColorScheme::Unknown: case Qt::ColorScheme::Unknown:
default: default: {
static QColor BLACK = QColor("Black"); static QColor BLACK = QColor("Black");
return BLACK; return BLACK;
} }
} }
}
class PGraphicsPixmapItem : public QGraphicsPixmapItem class PGraphicsPixmapItem : public QGraphicsPixmapItem
{ {
+9
View File
@@ -13,6 +13,15 @@
#include <optional> #include <optional>
// YYC MARK:
// <exdisp.h> is not self-contained: it only includes <rpc.h>/<rpcndr.h> before
// emitting `typedef interface ...` forward declarations, while the `interface`
// macro (defined as `struct` for C++) lives in <combaseapi.h>, which is pulled
// in via the <objbase.h> chain. Without this prelude, MSVC fails to parse those
// forward declarations (C2146/C2371) and every IShellWindows usage breaks.
// (Qt headers do not include <windows.h>, so nothing else provides it here.)
#include <objbase.h>
#include <exdisp.h> // IShellWindows, CLSID_ShellWindows #include <exdisp.h> // IShellWindows, CLSID_ShellWindows
#include <servprov.h> // IServiceProvider #include <servprov.h> // IServiceProvider
#include <shlguid.h> // SID_STopLevelBrowser #include <shlguid.h> // SID_STopLevelBrowser