From fb58c435efbb35d1a5bf1f982d3a5313e5004b77 Mon Sep 17 00:00:00 2001 From: Dominik Nussbaumer <4436784+tnixeu@users.noreply.github.com> Date: Wed, 28 Feb 2024 13:25:20 +0100 Subject: [PATCH] Fix ODR violations when using CMake unity builds. (#609) --- src/AutoHideTab.cpp | 5 ++--- src/DockAreaTitleBar.cpp | 5 ++--- src/DockWidgetTab.cpp | 5 ++--- src/FloatingDockContainer.cpp | 6 +++--- src/ads_globals.h | 1 + 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/AutoHideTab.cpp b/src/AutoHideTab.cpp index 248a6d1..e2d6265 100644 --- a/src/AutoHideTab.cpp +++ b/src/AutoHideTab.cpp @@ -44,7 +44,6 @@ namespace ads { -static const char* const LocationProperty = "Location"; /** * Private data class of CDockWidgetTab class (pimpl) @@ -102,7 +101,7 @@ struct AutoHideTabPrivate QMenu* Menu) { auto Action = Menu->addAction(Title); - Action->setProperty("Location", Location); + Action->setProperty(internal::LocationProperty, Location); QObject::connect(Action, &QAction::triggered, _this, &CAutoHideTab::onAutoHideToActionClicked); Action->setEnabled(Location != _this->sideBarLocation()); return Action; @@ -419,7 +418,7 @@ void CAutoHideTab::unpinDockWidget() //=========================================================================== void CAutoHideTab::onAutoHideToActionClicked() { - int Location = sender()->property(LocationProperty).toInt(); + int Location = sender()->property(internal::LocationProperty).toInt(); d->DockWidget->setAutoHide(true, (SideBarLocation)Location); } diff --git a/src/DockAreaTitleBar.cpp b/src/DockAreaTitleBar.cpp index 6e7a8d5..b3f42f9 100644 --- a/src/DockAreaTitleBar.cpp +++ b/src/DockAreaTitleBar.cpp @@ -60,7 +60,6 @@ namespace ads { -static const char* const LocationProperty = "Location"; /** * Private data class of CDockAreaTitleBar class (pimpl) @@ -159,7 +158,7 @@ struct DockAreaTitleBarPrivate QMenu* Menu) { auto Action = Menu->addAction(Title); - Action->setProperty("Location", Location); + Action->setProperty(internal::LocationProperty, Location); QObject::connect(Action, &QAction::triggered, _this, &CDockAreaTitleBar::onAutoHideToActionClicked); return Action; } @@ -569,7 +568,7 @@ void CDockAreaTitleBar::onAutoHideDockAreaActionClicked() //============================================================================ void CDockAreaTitleBar::onAutoHideToActionClicked() { - int Location = sender()->property(LocationProperty).toInt(); + int Location = sender()->property(internal::LocationProperty).toInt(); d->DockArea->toggleAutoHide((SideBarLocation)Location); } diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 0a8bdae..962de17 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -56,7 +56,6 @@ namespace ads { -static const char* const LocationProperty = "Location"; using tTabLabel = CElidingLabel; /** @@ -225,7 +224,7 @@ struct DockWidgetTabPrivate QMenu* Menu) { auto Action = Menu->addAction(Title); - Action->setProperty("Location", Location); + Action->setProperty(internal::LocationProperty, Location); QObject::connect(Action, &QAction::triggered, _this, &CDockWidgetTab::onAutoHideToActionClicked); return Action; } @@ -764,7 +763,7 @@ void CDockWidgetTab::autoHideDockWidget() //=========================================================================== void CDockWidgetTab::onAutoHideToActionClicked() { - int Location = sender()->property(LocationProperty).toInt(); + int Location = sender()->property(internal::LocationProperty).toInt(); d->DockWidget->toggleAutoHide((SideBarLocation)Location); } diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index e06e131..8dbfc70 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -357,7 +357,7 @@ static const char* windowsMessageString(int MessageId) #endif -static unsigned int zOrderCounter = 0; +static unsigned int zOrderCounterFloating = 0; /** * Private data class of CFloatingDockContainer class (pimpl) */ @@ -365,7 +365,7 @@ struct FloatingDockContainerPrivate { CFloatingDockContainer *_this; CDockContainerWidget *DockContainer; - unsigned int zOrderIndex = ++zOrderCounter; + unsigned int zOrderIndex = ++zOrderCounterFloating; QPointer DockManager; eDragState DraggingState = DraggingInactive; QPoint DragStartMousePosition; @@ -818,7 +818,7 @@ void CFloatingDockContainer::changeEvent(QEvent *event) if (isActiveWindow()) { ADS_PRINT("FloatingWidget::changeEvent QEvent::ActivationChange "); - d->zOrderIndex = ++zOrderCounter; + d->zOrderIndex = ++zOrderCounterFloating; #if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) if (d->DraggingState == DraggingFloatingWidget) diff --git a/src/ads_globals.h b/src/ads_globals.h index d3558aa..0de464b 100644 --- a/src/ads_globals.h +++ b/src/ads_globals.h @@ -167,6 +167,7 @@ static const bool RestoreTesting = true; static const bool Restore = false; static const char* const ClosedProperty = "close"; static const char* const DirtyProperty = "dirty"; +static const char* const LocationProperty = "Location"; extern const int FloatingWidgetDragStartEvent; extern const int DockedWidgetDragStartEvent;