Bug 316276

Summary: More than one "Previewer Output" component can appear at the same time.
Product: [Plasma] Plasma SDK Reporter: Tianyu Zhu <tian.tian098>
Component: GeneralAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: antonis.tsiapaliokas, giorgos.tsiapaliokas
Priority: NOR    
Version: 1.0   
Target Milestone: ---   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 1.1
Sentry Crash Report:
Attachments: Delete the old konsoleWidget when loading a new project.

Description Tianyu Zhu 2013-03-07 03:48:11 UTC
It seems that closing a project and then opening a new one does not destroy the old project's Previewer Output component. The effect is that every time a new project is loaded, a new Previewer Output is added to the window.

Reproducible: Always

Steps to Reproduce:
1. Load a plasmoid project
2. Close the project
3. Load another (maybe same) plasmoid project
Actual Results:  
Two Previewer Output components are shown at the bottom of the window.

Expected Results:  
Only one Previewer Output component should be shown.
Comment 1 Tianyu Zhu 2013-03-07 04:00:38 UTC
Created attachment 77824 [details]
Delete the old konsoleWidget when loading a new project.
Comment 2 Tianyu Zhu 2013-03-07 04:00:48 UTC
Honestly, the code should be using some RAII object to handle resources like KonsolePreviewer. For example, had the new C++11 std::unique_ptr been used instead of a raw pointers, the old KonsolePreviwer would have been deleted (and not leaked!) automatically after the new one was created.
Comment 3 Giorgos Tsiapaliokas 2013-03-07 11:32:25 UTC
Thank you for the patch.

Can you open a review at git.reviewboard.kde.org?
I would like to keep all the patches in the reviewboard
since more people will be able to see the code and receive
more feedback.