]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.4.2-bat.patch
Tweak debug
[bacula/bacula] / bacula / patches / 2.4.2-bat.patch
1
2  This patch should clean up two problems with bat:
3    1. Eliminate print error output concerning job plotting
4    2. Eliminate the error messages where bat complains about being busy.
5  It also backports some new trunk code.
6  Apply it to Bacula version 2.4.2 with:
7
8   cd <bacula-source>
9   patch -p0 <2.4.2-bat.patch
10   ./configure <your-options>
11   make
12   ...
13   make install
14
15   
16 Index: src/qt-console/mainwin.h
17 ===================================================================
18 --- src/qt-console/mainwin.h    (.../tags/Release-2.4.2/bacula) (revision 7468)
19 +++ src/qt-console/mainwin.h    (.../branches/Branch-2.4/bacula)        (revision 7468)
20 @@ -107,9 +107,7 @@
21     void runButtonClicked();
22     void estimateButtonClicked();
23     void browseButtonClicked();
24 -#ifdef HAVE_QWT
25     void jobPlotButtonClicked();
26 -#endif
27     void restoreButtonClicked();
28     void undockWindowButton();
29     void treeItemChanged(QTreeWidgetItem *, QTreeWidgetItem *);
30 Index: src/qt-console/fileset/fileset.h
31 ===================================================================
32 --- src/qt-console/fileset/fileset.h    (.../tags/Release-2.4.2/bacula) (revision 7468)
33 +++ src/qt-console/fileset/fileset.h    (.../branches/Branch-2.4/bacula)        (revision 7468)
34 @@ -62,6 +62,7 @@
35     void createContextMenu();
36     QString m_currentlyselected;
37     bool m_populated;
38 +   bool m_populating;
39     bool m_checkcurwidget;
40  };
41  
42 Index: src/qt-console/fileset/fileset.cpp
43 ===================================================================
44 --- src/qt-console/fileset/fileset.cpp  (.../tags/Release-2.4.2/bacula) (revision 7468)
45 +++ src/qt-console/fileset/fileset.cpp  (.../branches/Branch-2.4/bacula)        (revision 7468)
46 @@ -50,6 +50,7 @@
47  
48     /* mp_treeWidget, FileSet Tree Tree Widget inherited from ui_fileset.h */
49     m_populated = false;
50 +   m_populating = false;
51     m_checkcurwidget = true;
52     m_closeable = false;
53     readSettings();
54 @@ -70,6 +71,10 @@
55   */
56  void FileSet::populateTree()
57  {
58 +   if (m_populating)
59 +      return;
60 +   m_populating = true;
61 +
62     QTreeWidgetItem *filesetItem, *topItem;
63  
64     if (!m_console->preventInUseConnect())
65 @@ -102,7 +107,7 @@
66             " FROM FileSet"
67             " WHERE ";
68        query += " FileSet='" + filesetName + "'";
69 -      query += " ORDER BY FileSet";
70 +      query += " ORDER BY CreateTime DESC LIMIT 1";
71  
72        QStringList results;
73        if (mainWin->m_sqlDebug) {
74 @@ -135,7 +140,7 @@
75     for (int cnter=0; cnter<headerlist.size(); cnter++) {
76        mp_treeWidget->resizeColumnToContents(cnter);
77     }
78 -
79 +   m_populating = false;
80  }
81  
82  /*
83 Index: src/qt-console/clients/clients.cpp
84 ===================================================================
85 --- src/qt-console/clients/clients.cpp  (.../tags/Release-2.4.2/bacula) (revision 7468)
86 +++ src/qt-console/clients/clients.cpp  (.../branches/Branch-2.4/bacula)        (revision 7468)
87 @@ -51,6 +51,7 @@
88  
89     /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_client.h */
90     m_populated = false;
91 +   m_populating = false;
92     m_checkcurwidget = true;
93     m_closeable = false;
94     /* add context sensitive menu items specific to this classto the page
95 @@ -70,6 +71,9 @@
96   */
97  void Clients::populateTree()
98  {
99 +   if (m_populating)
100 +      return;
101 +   m_populating = true;
102     QTreeWidgetItem *clientItem, *topItem;
103  
104     if (!m_console->preventInUseConnect())
105 @@ -135,6 +139,7 @@
106     for(int cnter=0; cnter<headerlist.size(); cnter++) {
107        mp_treeWidget->resizeColumnToContents(cnter);
108     }
109 +   m_populating = false;
110  }
111  
112  /*
113 Index: src/qt-console/clients/clients.h
114 ===================================================================
115 --- src/qt-console/clients/clients.h    (.../tags/Release-2.4.2/bacula) (revision 7468)
116 +++ src/qt-console/clients/clients.h    (.../branches/Branch-2.4/bacula)        (revision 7468)
117 @@ -62,6 +62,7 @@
118     void createContextMenu();
119     QString m_currentlyselected;
120     bool m_populated;
121 +   bool m_populating;
122     bool m_checkcurwidget;
123  };
124  
125 Index: src/qt-console/storage/storage.cpp
126 ===================================================================
127 --- src/qt-console/storage/storage.cpp  (.../tags/Release-2.4.2/bacula) (revision 7468)
128 +++ src/qt-console/storage/storage.cpp  (.../branches/Branch-2.4/bacula)        (revision 7468)
129 @@ -52,6 +52,7 @@
130  
131     /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_storage.h */
132     m_populated = false;
133 +   m_populating = false;
134     m_checkcurwidget = true;
135     m_closeable = false;
136     m_currentStorage = "";
137 @@ -71,6 +72,9 @@
138   */
139  void Storage::populateTree()
140  {
141 +   if (m_populating)
142 +      return;
143 +   m_populating = true;
144     QTreeWidgetItem *storageItem, *topItem;
145  
146     if (!m_console->preventInUseConnect())
147 @@ -135,6 +139,7 @@
148     for(int cnter=0; cnter<headerlist.size(); cnter++) {
149        mp_treeWidget->resizeColumnToContents(cnter);
150     }
151 +   m_populating = false;
152  }
153  
154  /*
155 Index: src/qt-console/storage/storage.h
156 ===================================================================
157 --- src/qt-console/storage/storage.h    (.../tags/Release-2.4.2/bacula) (revision 7468)
158 +++ src/qt-console/storage/storage.h    (.../branches/Branch-2.4/bacula)        (revision 7468)
159 @@ -66,6 +66,7 @@
160     QString m_currentStorage;
161     int m_currentAutoChanger;
162     bool m_populated;
163 +   bool m_populating;
164     bool m_checkcurwidget;
165  };
166  
167 Index: src/qt-console/medialist/medialist.h
168 ===================================================================
169 --- src/qt-console/medialist/medialist.h        (.../tags/Release-2.4.2/bacula) (revision 7468)
170 +++ src/qt-console/medialist/medialist.h        (.../branches/Branch-2.4/bacula)        (revision 7468)
171 @@ -66,10 +66,13 @@
172  private:
173     void createContextMenu();
174     void setStatusColor(QTreeWidgetItem *, QString &, int &);
175 +   void writeExpandedSettings();
176     QString m_currentVolumeName;
177     QString m_currentVolumeId;
178     bool m_populated;
179 +   bool m_populating;
180     bool m_checkcurwidget;
181 +   QTreeWidgetItem *m_topItem;
182  };
183  
184  #endif /* _MEDIALIST_H_ */
185 Index: src/qt-console/medialist/medialist.cpp
186 ===================================================================
187 --- src/qt-console/medialist/medialist.cpp      (.../tags/Release-2.4.2/bacula) (revision 7468)
188 +++ src/qt-console/medialist/medialist.cpp      (.../branches/Branch-2.4/bacula)        (revision 7468)
189 @@ -54,6 +54,7 @@
190  
191     /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_medialist.h */
192     m_populated = false;
193 +   m_populating = false;
194     m_checkcurwidget = true;
195     m_closeable = false;
196     /* add context sensitive menu items specific to this classto the page
197 @@ -64,6 +65,8 @@
198  
199  MediaList::~MediaList()
200  {
201 +   if (m_populated)
202 +      writeExpandedSettings();
203  }
204  
205  /*
206 @@ -72,7 +75,10 @@
207   */
208  void MediaList::populateTree()
209  {
210 -   QTreeWidgetItem *mediatreeitem, *pooltreeitem, *topItem;
211 +   QTreeWidgetItem *mediatreeitem, *pooltreeitem;
212 +   if (m_populating)
213 +      return;
214 +   m_populating = true;
215  
216     if (!m_console->preventInUseConnect())
217         return;
218 @@ -85,23 +91,31 @@
219     int statusIndex = headerlist.indexOf("Status");
220  
221     m_checkcurwidget = false;
222 +   if (m_populated)
223 +      writeExpandedSettings();
224     mp_treeWidget->clear();
225     m_checkcurwidget = true;
226     mp_treeWidget->setColumnCount(headerlist.count());
227 -   topItem = new QTreeWidgetItem(mp_treeWidget);
228 -   topItem->setText(0, "Pools");
229 -   topItem->setData(0, Qt::UserRole, 0);
230 -   topItem->setExpanded(true);
231 +   m_topItem = new QTreeWidgetItem(mp_treeWidget);
232 +   m_topItem->setText(0, "Pools");
233 +   m_topItem->setData(0, Qt::UserRole, 0);
234 +   m_topItem->setExpanded(true);
235     
236     mp_treeWidget->setHeaderLabels(headerlist);
237  
238 +   QSettings settings(m_console->m_dir->name(), "bat");
239 +   settings.beginGroup("MediaListTreeExpanded");
240     QString query;
241  
242     foreach (QString pool_listItem, m_console->pool_list) {
243 -      pooltreeitem = new QTreeWidgetItem(topItem);
244 +      pooltreeitem = new QTreeWidgetItem(m_topItem);
245        pooltreeitem->setText(0, pool_listItem);
246        pooltreeitem->setData(0, Qt::UserRole, 1);
247 -      pooltreeitem->setExpanded(true);
248 +      if(settings.contains(pool_listItem)) {
249 +         pooltreeitem->setExpanded(settings.value(pool_listItem).toBool());
250 +      } else {
251 +         pooltreeitem->setExpanded(true);
252 +      }
253  
254        query =  "SELECT Media.VolumeName AS Media, "
255           " Media.MediaId AS Id, Media.VolStatus AS VolStatus,"
256 @@ -151,10 +165,12 @@
257           } /* foreach resultline */
258        } /* if results from query */
259     } /* foreach pool_listItem */
260 +   settings.endGroup();
261     /* Resize the columns */
262     for(int cnter=0; cnter<headerlist.count(); cnter++) {
263        mp_treeWidget->resizeColumnToContents(cnter);
264     }
265 +   m_populating = false;
266  }
267  
268  void MediaList::setStatusColor(QTreeWidgetItem *item, QString &field, int &index)
269 @@ -362,3 +378,18 @@
270     consoleCommand(cmd);
271     populateTree();
272  }
273 +
274 +/*
275 + * Write settings to save expanded states of the pools
276 + */
277 +void MediaList::writeExpandedSettings()
278 +{
279 +   QSettings settings(m_console->m_dir->name(), "bat");
280 +   settings.beginGroup("MediaListTreeExpanded");
281 +   int childcount = m_topItem->childCount();
282 +   for (int cnt=0; cnt<childcount; cnt++) {
283 +      QTreeWidgetItem *poolitem = m_topItem->child(cnt);
284 +      settings.setValue(poolitem->text(0), poolitem->isExpanded());
285 +   }
286 +   settings.endGroup();
287 +}
288 Index: src/qt-console/mainwin.cpp
289 ===================================================================
290 --- src/qt-console/mainwin.cpp  (.../tags/Release-2.4.2/bacula) (revision 7468)
291 +++ src/qt-console/mainwin.cpp  (.../branches/Branch-2.4/bacula)        (revision 7468)
292 @@ -441,14 +441,14 @@
293     new prerestorePage();
294  }
295  
296 -#ifdef HAVE_QWT
297  void MainWin::jobPlotButtonClicked()
298  {
299 +#ifdef HAVE_QWT
300     JobPlotPass pass;
301     pass.use = false;
302     new JobPlot(NULL, pass);
303 +#endif
304  }
305 -#endif
306  
307  /*
308   * The user just finished typing a line in the command line edit box
309 Index: src/qt-console/jobs/jobs.h
310 ===================================================================
311 --- src/qt-console/jobs/jobs.h  (.../tags/Release-2.4.2/bacula) (revision 7468)
312 +++ src/qt-console/jobs/jobs.h  (.../branches/Branch-2.4/bacula)        (revision 7468)
313 @@ -66,6 +66,7 @@
314     void createContextMenu();
315     QString m_currentlyselected;
316     bool m_populated;
317 +   bool m_populating;
318     bool m_checkcurwidget;
319     int m_typeIndex;
320  };
321 Index: src/qt-console/jobs/jobs.cpp
322 ===================================================================
323 --- src/qt-console/jobs/jobs.cpp        (.../tags/Release-2.4.2/bacula) (revision 7468)
324 +++ src/qt-console/jobs/jobs.cpp        (.../branches/Branch-2.4/bacula)        (revision 7468)
325 @@ -49,6 +49,7 @@
326  
327     /* mp_treeWidget, Storage Tree Tree Widget inherited from ui_client.h */
328     m_populated = false;
329 +   m_populating = false;
330     m_checkcurwidget = true;
331     m_closeable = false;
332     /* add context sensitive menu items specific to this classto the page
333 @@ -68,6 +69,9 @@
334   */
335  void Jobs::populateTree()
336  {
337 +   if (m_populating)
338 +      return;
339 +   m_populating = true;
340     QTreeWidgetItem *jobsItem, *topItem;
341  
342     if (!m_console->preventInUseConnect())
343 Index: src/qt-console/joblist/joblist.cpp
344 ===================================================================
345 --- src/qt-console/joblist/joblist.cpp  (.../tags/Release-2.4.2/bacula) (revision 7468)
346 +++ src/qt-console/joblist/joblist.cpp  (.../branches/Branch-2.4/bacula)        (revision 7468)
347 @@ -60,6 +60,7 @@
348  
349     m_resultCount = 0;
350     m_populated = false;
351 +   m_populating = false;
352     m_closeable = false;
353     if ((m_mediaName != "") || (m_clientName != "") || (m_jobName != "") || (m_filesetName != ""))
354        m_closeable=true;
355 @@ -106,6 +107,10 @@
356   */
357  void JobList::populateTable()
358  {
359 +   if (m_populating)
360 +      return;
361 +   m_populating = true;
362 +
363     QStringList results;
364     QString resultline;
365     QBrush blackBrush(Qt::black);
366 @@ -293,6 +298,7 @@
367            tr("The Jobs query returned no results.\n"
368           "Press OK to continue?"), QMessageBox::Ok );
369     }
370 +   m_populating = false;
371  }
372  
373  void JobList::setStatusColor(QTableWidgetItem *item, QString &field)
374 @@ -574,9 +580,9 @@
375  /*
376   * Graph this table
377   */
378 -#ifdef HAVE_QWT
379  void JobList::graphTable()
380  {
381 +#ifdef HAVE_QWT
382     JobPlotPass pass;
383     pass.recordLimitCheck = limitCheckBox->checkState();
384     pass.daysLimitCheck = daysCheckBox->checkState();
385 @@ -592,8 +598,8 @@
386     pass.use = true;
387     QTreeWidgetItem* pageSelectorTreeWidgetItem = mainWin->getFromHash(this);
388     new JobPlot(pageSelectorTreeWidgetItem, pass);
389 +#endif
390  }
391 -#endif
392  
393  /*
394   * Save user settings associated with this page
395 Index: src/qt-console/joblist/joblist.h
396 ===================================================================
397 --- src/qt-console/joblist/joblist.h    (.../tags/Release-2.4.2/bacula) (revision 7468)
398 +++ src/qt-console/joblist/joblist.h    (.../branches/Branch-2.4/bacula)        (revision 7468)
399 @@ -67,9 +67,7 @@
400     void preRestoreFromTime();
401     void showLogForJob();
402     void consoleCancelJob();
403 -#ifdef HAVE_QWT
404     void graphTable();
405 -#endif
406  
407  private:
408     void createConnections();
409 @@ -85,6 +83,7 @@
410     QString m_filesetName;
411     QString m_currentJob;
412     bool m_populated;
413 +   bool m_populating;
414     bool m_checkCurrentWidget;
415     int m_purgedIndex;
416     int m_typeIndex;