[haiku-commits] haiku: hrev48007 - in src/apps/haikudepot: ui model

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 12 Oct 2014 23:18:39 +0200 (CEST)

hrev48007 adds 3 changesets to branch 'master'
old head: c8b83b1708f438fc5a32d8d72a51b35d645fcfca
new head: 639756547d008e4355332055c66cdee050a26ba9
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=6397565+%5Ec8b83b1

----------------------------------------------------------------------------

1783f96: HaikuDepot: Show alert when scheduling package action failed

027e51a: HaikuDepot: Log more errors to stderr.
  
  These errors do not necessarily need to be reported to the user via alerts.
  They are more of an indication that HaikuDepot needs to be smarter when
  figuring out what package actions to present at all.

6397565: HaikuDepot: Move worker thread init into method
  
  ... and call it from the second version of the MainWindow constructor.

                                      [ Stephan Aßmus <superstippi@xxxxxx> ]

----------------------------------------------------------------------------

4 files changed, 43 insertions(+), 18 deletions(-)
src/apps/haikudepot/model/PackageManager.cpp |  4 +++
src/apps/haikudepot/ui/MainWindow.cpp        | 41 +++++++++++++++---------
src/apps/haikudepot/ui/MainWindow.h          |  1 +
src/apps/haikudepot/ui/PackageInfoView.cpp   | 15 +++++++--

############################################################################

Commit:      1783f96af9327b9f13176fbc32b4e34410f0c229
URL:         http://cgit.haiku-os.org/haiku/commit/?id=1783f96
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Oct 12 21:16:52 2014 UTC

HaikuDepot: Show alert when scheduling package action failed

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/ui/PackageInfoView.cpp 
b/src/apps/haikudepot/ui/PackageInfoView.cpp
index 1277978..eb1b6e6 100644
--- a/src/apps/haikudepot/ui/PackageInfoView.cpp
+++ b/src/apps/haikudepot/ui/PackageInfoView.cpp
@@ -8,6 +8,7 @@
 #include <algorithm>
 #include <stdio.h>
 
+#include <Alert.h>
 #include <Autolock.h>
 #include <Bitmap.h>
 #include <Button.h>
@@ -612,8 +613,18 @@ public:
                                                        
->SchedulePackageActions(actions);
                                                if (result != B_OK) {
                                                        fprintf(stderr, "Failed 
to schedule action: "
-                                                               "%s '%s'\n", 
action->Label(),
-                                                               
action->Package()->Title().String());
+                                                               "%s '%s': 
%s\n", action->Label(),
+                                                               
action->Package()->Title().String(),
+                                                               
strerror(result));
+                                                       BString 
message(B_TRANSLATE("The package action "
+                                                               "could not be 
scheduled: %Error%"));
+                                                       
message.ReplaceAll("%Error%", strerror(result));
+                                                       BAlert* alert = 
new(std::nothrow) BAlert(
+                                                               
B_TRANSLATE("Package action failed"),
+                                                               message, 
B_TRANSLATE("OK"), NULL, NULL,
+                                                               
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
+                                                       if (alert != NULL)
+                                                               alert->Go();
                                                }
                                        }
                                }

############################################################################

Commit:      027e51ae7d5c7f5185319264c7e722975ba6f77a
URL:         http://cgit.haiku-os.org/haiku/commit/?id=027e51a
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Oct 12 21:17:32 2014 UTC

HaikuDepot: Log more errors to stderr.

These errors do not necessarily need to be reported to the user via alerts.
They are more of an indication that HaikuDepot needs to be smarter when
figuring out what package actions to present at all.

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/model/PackageManager.cpp 
b/src/apps/haikudepot/model/PackageManager.cpp
index 4200899..83b42c0 100644
--- a/src/apps/haikudepot/model/PackageManager.cpp
+++ b/src/apps/haikudepot/model/PackageManager.cpp
@@ -127,9 +127,13 @@ public:
                                alert->Go(NULL);
                        return ex.Error();
                } catch (BAbortedByUserException ex) {
+                       fprintf(stderr, "Installation of package "
+                               "%s aborted by user: %s\n", packageName, 
ex.Message().String());
                        _SetDownloadedPackagesState(NONE);
                        return B_OK;
                } catch (BNothingToDoException ex) {
+                       fprintf(stderr, "Nothing to do while installing package 
"
+                               "%s: %s\n", packageName, ex.Message().String());
                        return B_OK;
                } catch (BException ex) {
                        fprintf(stderr, "Exception occurred while installing 
package "

############################################################################

Revision:    hrev48007
Commit:      639756547d008e4355332055c66cdee050a26ba9
URL:         http://cgit.haiku-os.org/haiku/commit/?id=6397565
Author:      Stephan Aßmus <superstippi@xxxxxx>
Date:        Sun Oct 12 21:18:58 2014 UTC

HaikuDepot: Move worker thread init into method

... and call it from the second version of the MainWindow constructor.

----------------------------------------------------------------------------

diff --git a/src/apps/haikudepot/ui/MainWindow.cpp 
b/src/apps/haikudepot/ui/MainWindow.cpp
index cd935e5..62f636b 100644
--- a/src/apps/haikudepot/ui/MainWindow.cpp
+++ b/src/apps/haikudepot/ui/MainWindow.cpp
@@ -165,21 +165,7 @@ MainWindow::MainWindow(BRect frame, const BMessage& 
settings)
 
        _StartRefreshWorker();
 
-       fPendingActionsSem = create_sem(0, "PendingPackageActions");
-       if (fPendingActionsSem >= 0) {
-               fPendingActionsWorker = spawn_thread(&_PackageActionWorker,
-                       "Planet Express", B_NORMAL_PRIORITY, this);
-               if (fPendingActionsWorker >= 0)
-                       resume_thread(fPendingActionsWorker);
-       }
-
-       fPackageToPopulateSem = create_sem(0, "PopulatePackage");
-       if (fPackageToPopulateSem >= 0) {
-               fPopulatePackageWorker = spawn_thread(&_PopulatePackageWorker,
-                       "Package Populator", B_NORMAL_PRIORITY, this);
-               if (fPopulatePackageWorker >= 0)
-                       resume_thread(fPopulatePackageWorker);
-       }
+       _InitWorkerThreads();
 }
 
 
@@ -214,6 +200,8 @@ MainWindow::MainWindow(BRect frame, const BMessage& 
settings,
        }
 
        fPackageInfoView->SetPackage(package);
+
+       _InitWorkerThreads();
 }
 
 
@@ -498,6 +486,27 @@ MainWindow::_BuildMenu(BMenuBar* menuBar)
 
 
 void
+MainWindow::_InitWorkerThreads()
+{
+       fPendingActionsSem = create_sem(0, "PendingPackageActions");
+       if (fPendingActionsSem >= 0) {
+               fPendingActionsWorker = spawn_thread(&_PackageActionWorker,
+                       "Planet Express", B_NORMAL_PRIORITY, this);
+               if (fPendingActionsWorker >= 0)
+                       resume_thread(fPendingActionsWorker);
+       }
+
+       fPackageToPopulateSem = create_sem(0, "PopulatePackage");
+       if (fPackageToPopulateSem >= 0) {
+               fPopulatePackageWorker = spawn_thread(&_PopulatePackageWorker,
+                       "Package Populator", B_NORMAL_PRIORITY, this);
+               if (fPopulatePackageWorker >= 0)
+                       resume_thread(fPopulatePackageWorker);
+       }
+}
+
+
+void
 MainWindow::_AdoptModel()
 {
        fVisiblePackages = fModel.CreatePackageList();
@@ -899,7 +908,7 @@ MainWindow::_PopulatePackageWorker(void* arg)
 void
 MainWindow::_NotifyUser(const char* title, const char* message)
 {
-       BAlert *alert = new(std::nothrow) BAlert(title, message,
+       BAlert* alert = new(std::nothrow) BAlert(title, message,
                B_TRANSLATE("Close"));
 
        if (alert != NULL)
diff --git a/src/apps/haikudepot/ui/MainWindow.h 
b/src/apps/haikudepot/ui/MainWindow.h
index fd8273b..18a494d 100644
--- a/src/apps/haikudepot/ui/MainWindow.h
+++ b/src/apps/haikudepot/ui/MainWindow.h
@@ -55,6 +55,7 @@ private:
 
 private:
                        void                            _BuildMenu(BMenuBar* 
menuBar);
+                       void                            _InitWorkerThreads();
                        void                            _AdoptModel();
 
                        void                            _AdoptPackage(const 
PackageInfoRef& package);


Other related posts:

  • » [haiku-commits] haiku: hrev48007 - in src/apps/haikudepot: ui model - superstippi