diff --git a/CMakeLists.txt b/CMakeLists.txt index ce35db45..2625b03e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -458,6 +458,7 @@ if(KDDockWidgets_TESTS) add_test(NAME tst_view COMMAND tst_view) add_test(NAME tst_window COMMAND tst_window) + add_test(NAME tst_droparea COMMAND tst_droparea) add_test(NAME tst_platform COMMAND tst_platform) add_test(NAME tst_viewguard COMMAND tst_viewguard) add_test(NAME tst_group COMMAND tst_group) diff --git a/src/controllers/DropArea.cpp b/src/controllers/DropArea.cpp index 42237726..e2582fd3 100644 --- a/src/controllers/DropArea.cpp +++ b/src/controllers/DropArea.cpp @@ -64,11 +64,11 @@ DropArea::DropArea(View *parent, MainWindowOptions options, bool isMDIWrapper) , m_dropIndicatorOverlay(createDropIndicatorOverlay(this)) , m_centralFrame(createCentralFrame(options)) { - Q_ASSERT(parent); setRootItem(new Layouting::ItemBoxContainer(view())); DockRegistry::self()->registerLayout(this); - setLayoutSize(parent->size()); + if (parent) + setLayoutSize(parent->size()); // Initialize min size updateSizeConstraints(); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 86aedc30..0055b97e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -69,6 +69,9 @@ target_link_libraries(tst_view kddockwidgets kdbindings) add_executable(tst_window tst_window.cpp ${TESTING_RESOURCES}) target_link_libraries(tst_window kddockwidgets kdbindings) +add_executable(tst_droparea tst_droparea.cpp ${TESTING_RESOURCES}) +target_link_libraries(tst_droparea kddockwidgets kdbindings) + add_executable(tst_platform tst_platform.cpp ${TESTING_RESOURCES}) target_link_libraries(tst_platform kddockwidgets kdbindings) diff --git a/tests/tst_droparea.cpp b/tests/tst_droparea.cpp new file mode 100644 index 00000000..50b489d2 --- /dev/null +++ b/tests/tst_droparea.cpp @@ -0,0 +1,20 @@ +/* + This file is part of KDDockWidgets. + + SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company + Author: Sérgio Martins + + SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only + + Contact KDAB at for commercial licensing options. +*/ + +#include "main.h" +#include "controllers/DropArea.h" +#include "Platform.h" + +TEST_CASE("DropArea CTOR") +{ + // Tests that ctor runs and doesn't leak + Controllers::DropArea da(nullptr, {}); +}