Summary: | Kst sometimes does not save plots in new windows | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Rick Chern <rchern> |
Component: | general | Assignee: | kst |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Proposed patch |
Description
Rick Chern
2004-08-13 19:48:05 UTC
Actually, the plot is there, but it has replaced one of the original plots in the first window (and the original plot is lost). This bug is critical and, if verified, must be fixed before release of 0.99. On August 13, 2004 01:48 pm, Rick Chern wrote: > ------- You are receiving this mail because: ------- > You are the assignee for the bug, or are watching the assignee. > > http://bugs.kde.org/show_bug.cgi?id=87146 > Summary: Kst sometimes does not save plots in new windows > Product: kst > Version: unspecified > Platform: Compiled Sources > OS/Version: Linux > Status: NEW > Severity: normal > Priority: NOR > Component: general > AssignedTo: kst kde org > ReportedBy: rchern interchange ubc ca > > > Version: 0.99-devel (using KDE KDE 3.2.1) > Installed from: Compiled From Sources > Compiler: gcc (GCC) 3.3.2 20031022 > OS: Linux > > When editing an existing kst file, exiting kst sometimes does not save the > file, even if "Yes" is clicked to the save prompt. > > How to reproduce: > - start kst > - use data wizard to produce some plots in one window > - save the kst session to a file > - exit kst > - start kst > - open the saved file > - select file->New window, and give the new window any name > - select Data->New Curve, and place the new curve in the new window (in a > new plot) - select File->Save > - select File->Quit > - start kst > - open the saved file > > Note that the new plot is not there. > _______________________________________________ > Kst mailing list > Kst@kde.org > https://mail.kde.org/mailman/listinfo/kst I'll start looking at it. Andrew -----Original Message----- From: Rick Chern [mailto:rchern@interchange.ubc.ca] Sent: Friday, August 13, 2004 10:48 AM To: kst@kde.org Subject: [Kst] [Bug 87146] New: Kst sometimes does not save plots in newwindows ------- You are receiving this mail because: ------- You are the assignee for the bug, or are watching the assignee. http://bugs.kde.org/show_bug.cgi?id=87146 Summary: Kst sometimes does not save plots in new windows Product: kst Version: unspecified Platform: Compiled Sources OS/Version: Linux Status: NEW Severity: normal Priority: NOR Component: general AssignedTo: kst kde org ReportedBy: rchern interchange ubc ca Version: 0.99-devel (using KDE KDE 3.2.1) Installed from: Compiled From Sources Compiler: gcc (GCC) 3.3.2 20031022 OS: Linux When editing an existing kst file, exiting kst sometimes does not save the file, even if "Yes" is clicked to the save prompt. How to reproduce: - start kst - use data wizard to produce some plots in one window - save the kst session to a file - exit kst - start kst - open the saved file - select file->New window, and give the new window any name - select Data->New Curve, and place the new curve in the new window (in a new plot) - select File->Save - select File->Quit - start kst - open the saved file Note that the new plot is not there. _______________________________________________ Kst mailing list Kst@kde.org https://mail.kde.org/mailman/listinfo/kst It appears the newly created plot was named P1, a duplicate of P1 in the original window. When loading, Kst seems to become confused about what P1 is. CVS commit by rchern: Check all windows for plot name when creating a new plot CCMAIL: 87146-done@bugs.kde.org M +57 -26 kstviewwindow.h 1.20 --- kdeextragear-2/kst/kst/kstviewwindow.h #1.19:1.20 @@ -30,4 +30,6 @@ #include <klocale.h> +#include "kst.h" +#include "kst2dplot.h" #include "kstdatacollection.h" #include "kstdefaultnames.h" @@ -101,36 +103,65 @@ class KstViewWindow : public KMdiChildVi template<class T> QString KstViewWindow::createPlot(const QString& suggestedName, bool prompt) { + + KstApp *app = KstApp::inst(); + KMdiIterator<KMdiChildView*> *iter; + QString name = suggestedName; + bool duplicate = true; + while (duplicate) { + duplicate = false; KstViewObjectPtr rc; - if (!name.isEmpty()) { - rc = _view->findChild(name); - } - - while (name.isEmpty() || rc) { + //check the name + iter = app->createIterator(); + while (iter->currentItem() && !duplicate) { + KMdiChildView *childview = iter->currentItem(); + KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview); + if (viewwindow) { + rc = viewwindow->view()->findChild(name); + if (rc) { + duplicate = true; name = KST::suggestPlotName(); - rc = _view->findChild(name); } - - if (!prompt) { - _view->createPlot<T>(name); - return name; + } + iter->next(); + } + app->deleteIterator(iter); } + if (prompt) { bool ok = false; - QString newName = name; - do { - newName = KLineEditDlg::getText(i18n("Enter a name for the new plot:"), newName, &ok, 0L); - if (ok) { - rc = _view->findChild(name); - if (!rc) { - _view->createPlot<T>(name); - return name; + name = KLineEditDlg::getText(i18n("Enter a name for the new plot:"), name, &ok, 0L); + if (!ok) { + return QString(); } - } else { - break; + //check the name + duplicate = true; + while (duplicate) { + duplicate = false; + KstViewObjectPtr rc; + //check the name + iter = app->createIterator(); + while (iter->currentItem() && !duplicate) { + KMdiChildView *childview = iter->currentItem(); + KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview); + if (viewwindow) { + rc = viewwindow->view()->findChild(name); + if (rc) { + duplicate = true; + name = KLineEditDlg::getText(i18n("Enter a name for the new plot:"), name, &ok, 0L); + if (!ok) { + app->deleteIterator(iter); + return QString(); } - } while(true); - - return QString::null; + } + } + iter->next(); + } + app->deleteIterator(iter); + } + } + //create the plot now + _view->createPlot<T>(name); + return name; } *** Bug 87166 has been marked as a duplicate of this bug. *** Plots with duplicate names can be manually created through the plot dialog. How to reproduce: - create some plots on in one window - create a new window - from the plot dialog, enter an existing plot name and click "Apply as New" for the new window. A new plot is created with duplicate name. This can cause problems with saving/loading kst files, and additionally, plots can be moved from one window to another, so they should not have duplicate names. However, this must be done manually on purpose, through the plot dialog. CVS commit by rchern: Check all windows for duplicate plot names when creating plots from the plot dialog CCMAIL:87146-done@bugs.kde.org M +23 -12 kstplotdialog_i.cpp 1.75 --- kdeextragear-2/kst/kst/kstplotdialog_i.cpp #1.74:1.75 @@ -529,9 +529,16 @@ void KstPlotDialogI::new_I() { } - // FIXME: might want to ensure that the plot name is not in any other window - /** verify that the plotname is unique */ - if (c) { - KstViewObjectPtr obj = static_cast<KstViewWindow*>(c)->view()->findChild(Name->text()); - if (obj) { + KstApp *app = KstApp::inst(); + KMdiIterator<KMdiChildView*> *iter; + QString name = Name->text(); + //check the name + KstViewObjectPtr rc; + iter = app->createIterator(); + while (iter->currentItem()) { + KMdiChildView *childview = iter->currentItem(); + KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview); + if (viewwindow) { + rc = viewwindow->view()->findChild(name); + if (rc) { QString message = i18n("Could not create a new plot.\n" "%1: not a unique plot name.\n" @@ -540,7 +547,11 @@ void KstPlotDialogI::new_I() { KMessageBox::sorry(this, message); Name->setFocus(); + app->deleteIterator(iter); return; } } + iter->next(); + } + app->deleteIterator(iter); Kst2DPlotPtr plot = static_cast<KstViewWindow*>(c)->view()->createPlot<Kst2DPlot>(Name->text()); Created attachment 7111 [details]
Proposed patch
Kst does not seem to check plot names at all when editing plots, resulting in duplicate plot names (and problems when loading saved kst files). Proposed patch attached above. CVS commit by rchern: Make sure checks for duplicate plot names are done for both new and edit plots. CCMAIL: 87146-done@bugs.kde.org M +39 -24 kstplotdialog_i.cpp 1.76 M +1 -1 kstplotdialog_i.h 1.30 --- kdeextragear-2/kst/kst/kstplotdialog_i.cpp #1.75:1.76 @@ -529,29 +529,8 @@ void KstPlotDialogI::new_I() { } - KstApp *app = KstApp::inst(); - KMdiIterator<KMdiChildView*> *iter; - QString name = Name->text(); - //check the name - KstViewObjectPtr rc; - iter = app->createIterator(); - while (iter->currentItem()) { - KMdiChildView *childview = iter->currentItem(); - KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview); - if (viewwindow) { - rc = viewwindow->view()->findChild(name); - if (rc) { - QString message = i18n("Could not create a new plot.\n" - "%1: not a unique plot name.\n" - "Change it to a unique name.").arg(Name->text()); - - KMessageBox::sorry(this, message); - Name->setFocus(); - app->deleteIterator(iter); + //check plot name + if (!checkPlotName()) { return; } - } - iter->next(); - } - app->deleteIterator(iter); Kst2DPlotPtr plot = static_cast<KstViewWindow*>(c)->view()->createPlot<Kst2DPlot>(Name->text()); @@ -611,4 +590,11 @@ void KstPlotDialogI::edit_I() { } + //check the plot name + if (Name->text() != Select->currentText()) { + if (!checkPlotName()) { + return; + } + } + KMdiChildView *c = KstApp::inst()->findWindow(_window->currentText()); if (!c) { @@ -1199,4 +1185,33 @@ void KstPlotDialogI::newWindow() { } +bool KstPlotDialogI::checkPlotName() { + KstApp *app = KstApp::inst(); + KMdiIterator<KMdiChildView*> *iter; + QString name = Name->text(); + //check the name + KstViewObjectPtr rc; + iter = app->createIterator(); + while (iter->currentItem()) { + KMdiChildView *childview = iter->currentItem(); + KstViewWindow *viewwindow = dynamic_cast<KstViewWindow*>(childview); + if (viewwindow) { + rc = viewwindow->view()->findChild(name); + if (rc) { + QString message = i18n("Could not create a new plot.\n" + "%1: not a unique plot name.\n" + "Change it to a unique name.").arg(Name->text()); + + KMessageBox::sorry(this, message); + Name->setFocus(); + app->deleteIterator(iter); + return false; + } + } + iter->next(); + } + app->deleteIterator(iter); + return true; +} + #include "kstplotdialog_i.moc" // vim: et ts=2 sw=2 --- kdeextragear-2/kst/kst/kstplotdialog_i.h #1.29:1.30 @@ -103,5 +103,5 @@ class KstPlotDialogI : public KstPlotDia private: void fill2DPlotList(Kst2DPlotList& plots); - + bool checkPlotName(); KstDoc *doc; KstLabel *SampleLabel; |