octave-maintainers
[Top][All Lists]
Advanced

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

Re: GUI integration


From: Mike Miller
Subject: Re: GUI integration
Date: Sat, 11 Aug 2012 19:07:00 -0400

On Sat, Aug 11, 2012 at 6:53 PM, Mike Miller wrote:
> On Sat, Aug 11, 2012 at 6:37 PM, John W. Eaton wrote:
>> On 11-Aug-2012, Mike Miller wrote:
>>
>> | On Sat, Aug 11, 2012 at 5:59 PM, John W. Eaton <address@hidden> wrote:
>> |
>> | > I checked in the following change:
>> | >
>> | >   http://hg.savannah.gnu.org/hgweb/octave/rev/098546e95a5e
>> |
>> | With this revision I get a segfault when running after make install
>> | and no ~/.config/octave directory. If I ./run-octave first and let it
>> | create ~/.config/octave, then the installed copy of octave runs fine.
>> | Maybe install_defaults() hasn't been called yet?
>> |
>> | Here's a gdb backtrace:
>> | #0  0x00007ffff47e8f4b in std::basic_string<char,
>> | std::char_traits<char>, std::allocator<char>
>> | >::basic_string(std::string const&) ()
>> |    from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
>> | #1  0x00007ffff4ca0805 in operator+<char, std::char_traits<char>,
>> | std::allocator<char> > (__rhs=..., __lhs=...) at
>> | /usr/include/c++/4.7/bits/basic_string.h:2365
>> | #2  default_qt_settings_file () at 
>> ../../../gui/gui/src/resource-manager.cc:67
>>
>> It works for me.
>>
>> The call to install_defaults happens in octave_initialize_interpreter,
>> which is the first thing called in main, before calling
>> octave_start_gui.
>>
>> Please set a breakpoint in default_qt_settings_file and step through
>> it and examine the values of Voct_etc_dir and file_ops::dir_sep_str()
>> before the crash.
>
> Got it, resource_manager is initializing its instance before main is
> called, a static singleton rather than created on-demand.

Confirmed, the following quick and dirty change gets rid of the
segfault for me. I get the "Welcome to Octave!" dialog again, however
it's still stuck in an endless loop, is this supposed to be working
yet?


diff --git a/gui/src/resource-manager.cc b/gui/src/resource-manager.cc
--- a/gui/src/resource-manager.cc
+++ b/gui/src/resource-manager.cc
@@ -32,7 +32,7 @@

 #include "resource-manager.h"

-resource_manager resource_manager::_singleton;
+resource_manager *resource_manager::_singleton;

 resource_manager::resource_manager ()
 {
diff --git a/gui/src/resource-manager.h b/gui/src/resource-manager.h
--- a/gui/src/resource-manager.h
+++ b/gui/src/resource-manager.h
@@ -32,7 +32,8 @@
   static resource_manager *
   instance ()
   {
-    return &_singleton;
+    if (!_singleton) _singleton = new resource_manager ();
+    return _singleton;
   }

   QSettings *get_settings ();
@@ -50,7 +51,7 @@

   QSettings *_settings;
   QString _home_path;
-  static resource_manager _singleton;
+  static resource_manager *_singleton;
   bool _first_run;
 };



-- 
mike


reply via email to

[Prev in Thread] Current Thread [Next in Thread]