Browse Source

Cache result of ticables_is_usb_enabled so the check isn't run over and over again.

git-svn-id: file:///var/svn/tigccpp/trunk@712 9552661e-59e3-4036-b4f2-dbe53926924f
kevinkofler 18 years ago
parent
commit
61ff7b694f
4 changed files with 6 additions and 4 deletions
  1. 1 0
      ktigcc/ktigcc.h
  2. 2 0
      ktigcc/mainform.ui.h
  3. 1 2
      ktigcc/preferences.cpp
  4. 2 2
      ktigcc/preferencesdlg.ui.h

+ 1 - 0
ktigcc/ktigcc.h

@@ -33,6 +33,7 @@ extern const char *tigcc_base;
 extern const char *quill_drv;
 extern bool have_fargo;
 extern bool have_flashos;
+extern bool have_usb;
 extern char tempdir[];
 void write_temp_file(const char *filename, const char *data, const size_t len);
 void delete_temp_file(const char *filename);

+ 2 - 0
ktigcc/mainform.ui.h

@@ -407,6 +407,7 @@ static QListViewItem *findCurrentDocument;
 static unsigned findCurrentLine;
 QPtrList<SourceFile> sourceFiles;
 static QPopupMenu *findFunctionsPopup;
+bool have_usb;
 
 class DnDListView : public KListView {
   private:
@@ -949,6 +950,7 @@ void MainForm::init()
   ticables_library_init();
   tifiles_library_init();
   ticalcs_library_init();
+  have_usb=ticables_is_usb_enabled();
   compiling=FALSE;
   headersModified=FALSE;
   loadPreferences();

+ 1 - 2
ktigcc/preferences.cpp

@@ -35,7 +35,6 @@
 #include "preferences.h"
 #include "preferencesdlg.h"
 #include "tpr.h"
-#include <ticables.h>
 
 TIGCCPrefs preferences;
 
@@ -1257,7 +1256,7 @@ void loadPreferences(void)
   preferences.linkCable=(CableModel)pconfig->readNumEntry("Link Cable",CABLE_GRY);
   // Don't allow selecting a USB cable if libticables2 hasn't been compiled
   // without USB support or if USB support can't be used.
-  if (!ticables_is_usb_enabled()) {
+  if (!have_usb) {
     if (preferences.linkCable==CABLE_SLV || preferences.linkCable==CABLE_USB) {
       preferences.linkCable=CABLE_GRY;
       preferences.linkTarget=LT_NONE;

+ 2 - 2
ktigcc/preferencesdlg.ui.h

@@ -37,7 +37,7 @@
 #include <knuminput.h>
 #include <kfontdialog.h>
 #include <kcolordialog.h>
-#include <ticables.h>
+#include "ktigcc.h"
 
 void Preferences::init()
 {
@@ -100,7 +100,7 @@ void Preferences::init()
 
   // Don't allow selecting a USB cable if libticables2 hasn't been compiled
   // without USB support or if USB support can't be used.
-  if (!ticables_is_usb_enabled()) {
+  if (!have_usb) {
     if (silverLink->isChecked() || directLink->isChecked()) {
       grayLink->setChecked(TRUE);
       targetNone->setChecked(TRUE);