[Ktutorial-commits] SF.net SVN: ktutorial:[288] trunk/ktutorial/ktutorial-library
Status: Alpha
Brought to you by:
danxuliu
From: <dan...@us...> - 2011-01-28 10:59:17
|
Revision: 288 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=288&view=rev Author: danxuliu Date: 2011-01-28 10:59:11 +0000 (Fri, 28 Jan 2011) Log Message: ----------- Fix crash when the StepTextWidget highlighted a widget, the widget was destroyed and then the StepTextWidget tried to stop the highlighting. Modified Paths: -------------- trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.h trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp Modified: trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.h =================================================================== --- trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.h 2010-10-31 20:37:40 UTC (rev 287) +++ trunk/ktutorial/ktutorial-library/src/view/StepTextWidget.h 2011-01-28 10:59:11 UTC (rev 288) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -19,6 +19,8 @@ #ifndef VIEW_STEPTEXTWIDGET_H #define VIEW_STEPTEXTWIDGET_H +#include <QPointer> + #include <KTextEdit> namespace view { @@ -136,7 +138,7 @@ * The widget currently being highlighted as a result of activating a link * in this StepTextWidget. */ - QWidget* mCurrentHighlightedWidget; + QPointer<QWidget> mCurrentHighlightedWidget; /** * Returns the size for the given text width. Modified: trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp =================================================================== --- trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp 2010-10-31 20:37:40 UTC (rev 287) +++ trunk/ktutorial/ktutorial-library/tests/view/StepTextWidgetTest.cpp 2011-01-28 10:59:11 UTC (rev 288) @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2010 by Daniel Calviño Sánchez * + * Copyright (C) 2010-2011 by Daniel Calviño Sánchez * * dan...@gm... * * * * This program is free software; you can redistribute it and/or modify * @@ -60,6 +60,7 @@ void testSetTextWhenWidgetIsBeingHighlighted(); void testDeleteWhenWidgetIsBeingHighlighted(); + void testDeleteWhenHighlightedWidgetWasDestroyed(); private: @@ -359,6 +360,27 @@ QVERIFY(!widgetToHighlight->findChild<WidgetHighlighter*>("")); } +void StepTextWidgetTest::testDeleteWhenHighlightedWidgetWasDestroyed() { + KXmlGuiWindow mainWindow; + KTutorial::self()->setup(&mainWindow); + QWidget* widgetToHighlight = new QWidget(&mainWindow); + widgetToHighlight->setObjectName("widgetName"); + + StepTextWidget* widget = new StepTextWidget(); + widget->setText("The <a href=\"widget:widgetName\">widget to highlight</a>"); + widget->show(); + + QPoint position = centerOfText(*widget, "widget to highlight"); + QTest::mouseClick(widget->viewport(), Qt::LeftButton, Qt::NoModifier, + position, 500); + + delete widgetToHighlight; + + delete widget; + + //No explicit check is made, if it does not crash everything is fine ;) +} + /////////////////////////////////// Helpers //////////////////////////////////// void StepTextWidgetTest::selectFirstContextMenuOption() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |