[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bacula-devel] BAT Patch: Recycle Pool in 'mediaedit'

Hi, Dirk,

I hope you do not mind, but I would like to suggest a modification
to the behaviour of the mediaedit dialog in BAT, WRT the Recycle

Currently, the code will work exactly as expected if the Volume's
recycle pool is explicitly set to a pool (Media.RecyclePoolId != 0).
However, if RecyclePoolId is set to 0 (the default, and this does
not mean the Default pool), the following will happen when the
recyclePoolCombo combo box is initialised (in MediaEdit::MediaEdit)

1     recyclePoolCombo->addItems(m_console->pool_list);
2     index = recyclePoolCombo->findText(m_recyclePool, Qt::MatchExactly);
     if (index == -1) {
        recyclePoolCombo->insertItem(0, "");
3        index = recyclePoolCombo->findText(m_recyclePool, Qt::MatchExactly);
4     if (index != -1) {

Notes (in the leftmost column above):

1 The list of pools is added to the combo's list, and (I assume) the
 first item is automatically selected as the current value, which
 will be the Default pool

2 If Media.RecyclePoolId is 0, then m_recyclePool will actually have
 the value "*NULL*", so the text will not be found in the list and
 index will be assigned the value of -1

3 Again, because m_recyclePool is "*NULL*", it will not be found in
 the list (I assume the code intended the blank item, inserted by the
 previous line of code, to be matched here). So index will again be
 assigned -1

4 Nothing will be done here, so the combo will (I assume) retain the
 original value which it had before the blank item was added.

As a result, a volume with no recycle pool set will be offered the
first pool (probably Default) in the mediaedit dialog.

No problem, one would think, just always remember to select the first,
blank, item before hitting the OK button, yes?

No. In MediaEdit::okButtonPushed is the following code:

  if (m_recyclePool != recyclePoolCombo->currentText()) {
     scmd += " recyclepool=\"" + recyclePoolCombo->currentText() + "\"";
     docmd = true;

and, since m_recyclePool is "*NULL*" and recyclePoolCombo->currentText()
is "", then the condition will be true, and recyclepool="" will be added
to scmd, resulting in the director replying:

Could not find Pool "": ERR=Pool record not found in Catalog.

I suggest the attached patch, which will (A) make the constructor select
the blank item if it (the blank item) is added to the combo box list,
and (B) change the OK button behaviour so that selecting the blank item
always means no change will be made to RecyclePoolId.

Index: src/qt-console/mediaedit/mediaedit.cpp
--- src/qt-console/mediaedit/mediaedit.cpp	(revision 6488)
+++ src/qt-console/mediaedit/mediaedit.cpp	(working copy)
@@ -187,11 +187,9 @@
       index = recyclePoolCombo->findText(m_recyclePool, Qt::MatchExactly);
       if (index == -1) {
          recyclePoolCombo->insertItem(0, "");
-         index = recyclePoolCombo->findText(m_recyclePool, Qt::MatchExactly);
+         index = 0;
-      if (index != -1) {
-         recyclePoolCombo->setCurrentIndex(index);
-      }
+      recyclePoolCombo->setCurrentIndex(index);
    } else {
       QMessageBox::warning(this, tr("No Volume name"), tr("No Volume name given"),
                            QMessageBox::Ok, QMessageBox::Ok);
@@ -257,7 +255,7 @@
       scmd += " enabled=yes";
       docmd = true;
-   if (m_recyclePool != recyclePoolCombo->currentText()) {
+   if (m_recyclePool != recyclePoolCombo->currentText() && recyclePoolCombo->currentText() != "") {
       scmd += " recyclepool=\"" + recyclePoolCombo->currentText() + "\"";
       docmd = true;
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
Bacula-devel mailing list

This mailing list archive is a service of Copilot Consulting.