From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 126377 invoked by alias); 7 Nov 2017 18:17:51 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 126321 invoked by uid 89); 7 Nov 2017 18:17:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=consolidation, determining, sk:upgrade X-HELO: rgout02.bt.lon5.cpcloud.co.uk Received: from rgout0202.bt.lon5.cpcloud.co.uk (HELO rgout02.bt.lon5.cpcloud.co.uk) (65.20.0.201) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Nov 2017 18:17:48 +0000 X-OWM-Source-IP: 86.162.230.154 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-Junkmail-Premium-Raw: score=7/50,refid=2.7.2:2017.11.7.174516:17:7.944,ip=,rules=__HAS_FROM, __TO_MALFORMED_2, __TO_NO_NAME, __HAS_CC_HDR, __CC_NAME, __CC_NAME_DIFF_FROM_ACC, __SUBJ_ALPHA_END, __HAS_MSGID, __SANE_MSGID, __HAS_X_MAILER, __IN_REP_TO, __REFERENCES, __FROM_DOMAIN_IN_ANY_CC1, __ANY_URI, __URI_NO_MAILTO, __URI_NO_WWW, __NO_HTML_TAG_RAW, __MIME_TEXT_P1, __MIME_TEXT_ONLY, HTML_00_01, HTML_00_10, IN_REP_TO, MSG_THREAD, __FROM_DOMAIN_IN_RCPT, __CC_REAL_NAMES, MULTIPLE_REAL_RCPTS, LEGITIMATE_SIGNS, __MIME_TEXT_P, REFERENCES, NO_URI_HTTPS Received: from localhost.localdomain (86.162.230.154) by rgout02.bt.lon5.cpcloud.co.uk (9.0.019.13-1) (authenticated as jonturney@btinternet.com) id 59D91D94034C7A90; Tue, 7 Nov 2017 18:17:47 +0000 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup 4/5] Correctly order preparing packagedb for chooser Date: Tue, 07 Nov 2017 18:17:00 -0000 Message-Id: <20171107181703.51016-4-jon.turney@dronecode.org.uk> In-Reply-To: <20171107181703.51016-1-jon.turney@dronecode.org.uk> References: <20171107181703.51016-1-jon.turney@dronecode.org.uk> X-SW-Source: 2017-11/txt/msg00023.txt.bz2 Do packagedb::prep() in ChooserPage::OnActivate(), as doing it in OnInit() is wrong, as that only gets called once (but lazily). Make packagedb::prep() idempotent after packagedb::init(), so it doesn't do it's work again, if we come back to chooser from a later page. Re-arrange applying command line package selection, and determining the initial solution, which should only happen once, but after packagedb::prep() --- choose.cc | 81 +++++++++++++++++++++++++++++++++-------------------------- choose.h | 3 +++ package_db.cc | 30 ++++++++++++++++++++++ package_db.h | 23 +++++++++++------ 4 files changed, 93 insertions(+), 44 deletions(-) diff --git a/choose.cc b/choose.cc index 3a990d5..00e5977 100644 --- a/choose.cc +++ b/choose.cc @@ -61,7 +61,6 @@ static BoolOption UpgradeAlsoOption (false, 'g', "upgrade-also", "also upgrade i static BoolOption CleanOrphansOption (false, 'o', "delete-orphans", "remove orphaned packages"); static BoolOption ForceCurrentOption (false, 'f', "force-current", "select the current version for all packages"); static BoolOption PruneInstallOption (false, 'Y', "prune-install", "prune the installation to only the requested packages"); -static BoolOption MirrorOption (false, 'm', "mirror-mode", "Skip availability check when installing from local directory (requires local directory to be clean mirror!)"); using namespace std; @@ -89,7 +88,7 @@ static ControlAdjuster::ControlInfo ChooserControlsInfo[] = { ChooserPage::ChooserPage () : cmd_show_set (false), saved_geom (false), saw_geom_change (false), - timer_id (DEFAULT_TIMER_ID) + timer_id (DEFAULT_TIMER_ID), activated (false) { sizeProcessor.AddControlInfo (ChooserControlsInfo); @@ -150,7 +149,12 @@ ChooserPage::createListview () chooser->setViewMode (!is_new_install || UpgradeAlsoOption || hasManualSelections ? PickView::views::PackagePending : PickView::views::Category); SendMessage (GetDlgItem (IDC_CHOOSE_VIEW), CB_SETCURSEL, (WPARAM)chooser->getViewMode(), 0); + ClearBusy (); +} +void +ChooserPage::initialUpdateState() +{ // set the initial update state if (ForceCurrentOption) { @@ -171,8 +175,6 @@ ChooserPage::createListview () static int ta[] = { IDC_CHOOSE_KEEP, IDC_CHOOSE_BEST, IDC_CHOOSE_SYNC, 0 }; rbset (GetHWND (), ta, update_mode_id); - - ClearBusy (); } /* TODO: review ::overrides for possible consolidation */ @@ -263,20 +265,30 @@ ChooserPage::OnInit () SendMessage(viewlist, CB_ADDSTRING, 0, (LPARAM)PickView::mode_caption((PickView::views)view)); } - SetBusy (); - packagedb db; - db.makeBase(); - db.read(); - db.upgrade(); - db.fixup_source_package_ids(); - db.removeEmptyCategories(); + if (source == IDC_SOURCE_DOWNLOAD) + setPrompt("Select packages to download "); + else + setPrompt("Select packages to install "); - if (source == IDC_SOURCE_DOWNLOAD || source == IDC_SOURCE_LOCALDIR) - packagemeta::ScanDownloadedFiles (MirrorOption); + createListview (); - db.setExistence (); - db.fillMissingCategory (); + AddTooltip (IDC_CHOOSE_KEEP, IDS_TRUSTKEEP_TOOLTIP); + AddTooltip (IDC_CHOOSE_BEST, IDS_TRUSTCURR_TOOLTIP); + AddTooltip (IDC_CHOOSE_SYNC, IDS_TRUSTSYNC_TOOLTIP); + AddTooltip (IDC_CHOOSE_EXP, IDS_TRUSTEXP_TOOLTIP); + AddTooltip (IDC_CHOOSE_VIEW, IDS_VIEWBUTTON_TOOLTIP); + AddTooltip (IDC_CHOOSE_HIDE, IDS_HIDEOBS_TOOLTIP); + AddTooltip (IDC_CHOOSE_SEARCH_EDIT, IDS_SEARCH_TOOLTIP); + + /* Set focus to search edittext control. */ + PostMessage (GetHWND (), WM_NEXTDLGCTL, + (WPARAM) GetDlgItem (IDC_CHOOSE_SEARCH_EDIT), TRUE); +} +void +ChooserPage::applyCommandLinePackageSelection() +{ + packagedb db; for (packagedb::packagecollection::iterator i = db.packages.begin (); i != db.packages.end (); ++i) { @@ -303,32 +315,29 @@ ChooserPage::OnInit () else pkg.set_action (packagemeta::Default_action, pkg.installed); } - - ClearBusy (); - - if (source == IDC_SOURCE_DOWNLOAD) - setPrompt("Select packages to download "); - else - setPrompt("Select packages to install "); - createListview (); - - AddTooltip (IDC_CHOOSE_KEEP, IDS_TRUSTKEEP_TOOLTIP); - AddTooltip (IDC_CHOOSE_BEST, IDS_TRUSTCURR_TOOLTIP); - AddTooltip (IDC_CHOOSE_SYNC, IDS_TRUSTSYNC_TOOLTIP); - AddTooltip (IDC_CHOOSE_EXP, IDS_TRUSTEXP_TOOLTIP); - AddTooltip (IDC_CHOOSE_VIEW, IDS_VIEWBUTTON_TOOLTIP); - AddTooltip (IDC_CHOOSE_HIDE, IDS_HIDEOBS_TOOLTIP); - AddTooltip (IDC_CHOOSE_SEARCH_EDIT, IDS_SEARCH_TOOLTIP); - - /* Set focus to search edittext control. */ - PostMessage (GetHWND (), WM_NEXTDLGCTL, - (WPARAM) GetDlgItem (IDC_CHOOSE_SEARCH_EDIT), TRUE); } void ChooserPage::OnActivate() { - chooser->refresh();; + SetBusy(); + + packagedb db; + db.prep(); + + if (!activated) + { + // Do things which should only happen once, but rely on packagedb being + // ready to use, so OnInit() is too early + applyCommandLinePackageSelection(); + initialUpdateState(); + + activated = true; + } + + ClearBusy(); + + chooser->refresh(); PlaceDialog (true); } diff --git a/choose.h b/choose.h index 6839b0b..32a1650 100644 --- a/choose.h +++ b/choose.h @@ -59,6 +59,8 @@ private: void logResults(); void setPrompt(char const *aPrompt); void PlaceDialog (bool); + void applyCommandLinePackageSelection(); + void initialUpdateState(); PickView *chooser; static HWND ins_dialog; @@ -74,6 +76,7 @@ private: UINT wpi[sizeof (WINDOWPLACEMENT) / sizeof (UINT)]; }; int update_mode_id; + bool activated; }; #endif /* SETUP_CHOOSE_H */ diff --git a/package_db.cc b/package_db.cc index 8fbec44..92fe4f9 100644 --- a/package_db.cc +++ b/package_db.cc @@ -40,6 +40,9 @@ #include "resource.h" #include "libsolv.h" #include "csu_util/version_compare.h" +#include "getopt++/BoolOption.h" + +static BoolOption MirrorOption (false, 'm', "mirror-mode", "Skip availability check when installing from local directory (requires local directory to be clean mirror!)"); using namespace std; @@ -52,6 +55,8 @@ packagedb::init () { installeddbread = 0; installeddbver = 0; + prepped = false; + packages.clear(); sourcePackages.clear(); categories.clear(); @@ -382,6 +387,7 @@ packagedb::findSourceVersion (PackageSpecification const &spec) const int packagedb::installeddbread = 0; int packagedb::installeddbver = 0; +bool packagedb::prepped = false; packagedb::packagecollection packagedb::packages; packagedb::categoriesType packagedb::categories; packagedb::packagecollection packagedb::sourcePackages; @@ -717,3 +723,27 @@ packagedb::fixup_source_package_ids() } } } + +void +packagedb::prep() +{ + /* make packagedb ready for use for chooser */ + if (prepped) + return; + + makeBase(); + read(); + upgrade(); + fixup_source_package_ids(); + removeEmptyCategories(); + + /* XXX: this needs to be broken out somewhere where it can do progress + reporting, as it can take a long time... */ + if (source == IDC_SOURCE_DOWNLOAD || source ==IDC_SOURCE_LOCALDIR) + packagemeta::ScanDownloadedFiles (MirrorOption); + + setExistence (); + fillMissingCategory (); + + prepped = true; +} diff --git a/package_db.h b/package_db.h index a26c387..e500e4b 100644 --- a/package_db.h +++ b/package_db.h @@ -65,24 +65,21 @@ class packagedb public: packagedb (); void init(); - void read(); - void makeBase(); /* 0 on success */ int flush (); - void upgrade (); + void prep(); + packagemeta * findBinary (PackageSpecification const &) const; packageversion findBinaryVersion (PackageSpecification const &) const; packagemeta * findSource (PackageSpecification const &) const; packageversion findSourceVersion (PackageSpecification const &spec) const; packagemeta * addBinary (const std::string &pkgname, const SolverPool::addPackageData &pkgdata); packageversion addSource (const std::string &pkgname, const SolverPool::addPackageData &pkgdata); - void fixup_source_package_ids(); + PackageDBConnectedIterator connectedBegin(); PackageDBConnectedIterator connectedEnd(); - void fillMissingCategory(); + void defaultTrust (SolverTasks &q, SolverSolution::updateMode mode, bool test); - void setExistence(); - void removeEmptyCategories(); typedef std::map packagecollection; /* all seen binary packages */ @@ -100,11 +97,21 @@ public: static SolverSolution solution; private: + void makeBase(); + void read(); + void upgrade (); + void fixup_source_package_ids(); + void removeEmptyCategories(); + void fillMissingCategory(); + void setExistence(); + void guessUserPicked(void); + static int installeddbread; /* do we have to reread this */ static int installeddbver; + static bool prepped; + friend class ConnectedLoopFinder; static std::vector dependencyOrderedPackages; - void guessUserPicked(void); }; #endif /* SETUP_PACKAGE_DB_H */ -- 2.15.0