Mercurial > hg > octave-nkf
changeset 19521:cbc838b3020c
maint: Periodic merge of gui-release to default.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 12 Nov 2014 20:04:52 -0800 |
parents | 5b263e517c95 (current diff) 91cd85a75705 (diff) |
children | 1f4455ff2329 |
files | libgui/src/octave-qt-link.cc libgui/src/settings-dialog.cc libinterp/corefcn/profiler.cc libinterp/octave-value/ov-usr-fcn.cc |
diffstat | 14 files changed, 110 insertions(+), 75 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -1881,6 +1881,8 @@ (settings->value ("editor/backspace_unindents_line",false).toBool ()); _edit_area->setIndentationGuides (settings->value ("editor/show_indent_guides",false).toBool ()); + _edit_area->setIndentationsUseTabs + (settings->value ("editor/indent_uses_tabs",false).toBool ()); _edit_area->setTabWidth (settings->value ("editor/tab_width",2).toInt ());
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -404,27 +404,31 @@ else { // File does not exist, should it be crated? + bool create_file = true; QMessageBox *msgBox; - int answer; QSettings *settings = resource_manager::get_settings (); - if (settings->value ("editor/create_new_file", false).toBool ()) - { - answer = QMessageBox::Yes; - } - else + + if (!settings->value ("editor/create_new_file", false).toBool ()) { msgBox = new QMessageBox (QMessageBox::Question, tr ("Octave Editor"), tr ("File\n%1\ndoes not exist. " "Do you want to create it?").arg (openFileName), - QMessageBox::Yes - | QMessageBox::No, 0); + QMessageBox::NoButton,0); + QPushButton *create_button = + msgBox->addButton (tr ("Create"), QMessageBox::YesRole); + msgBox->addButton (tr ("Cancel"), QMessageBox::RejectRole); + msgBox->setDefaultButton (create_button); + msgBox->exec (); - msgBox->setAttribute (Qt::WA_DeleteOnClose); - answer = msgBox->exec (); + QAbstractButton *clicked_button = msgBox->clickedButton (); + if (clicked_button != create_button) + create_file = false; + + delete msgBox; } - if (answer == QMessageBox::Yes) + if (create_file) { // create the file and call the editor again QFile file (openFileName);
--- a/libgui/src/octave-qt-link.cc +++ b/libgui/src/octave-qt-link.cc @@ -93,21 +93,21 @@ QFileInfo file_info (QString::fromStdString (file)); QStringList btn; QStringList role; - role << "AcceptRole" << "AcceptRole"; - btn << tr ("Yes") << tr ("No"); + role << "YesRole" << "RejectRole"; + btn << tr ("Create") << tr ("Cancel"); uiwidget_creator.signal_dialog ( tr ("File\n%1\ndoes not exist. Do you want to create it?"). arg (QDir::currentPath () + QDir::separator () + QString::fromStdString (file)), - tr ("Octave Editor"), "quest", btn, tr ("Yes"), role); + tr ("Octave Editor"), "quest", btn, tr ("Create"), role ); // Wait while the user is responding to message box. uiwidget_creator.wait (); // The GUI has sent a signal and the process has been awakened. QString answer = uiwidget_creator.get_dialog_button (); - return (answer == tr ("Yes")); + return (answer == tr ("Create")); } int
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -210,6 +210,8 @@ settings->value ("editor/show_indent_guides",false).toBool ()); ui->editor_ind_width_spinbox->setValue ( settings->value ("editor/indent_width", 2).toInt ()); + ui->editor_ind_uses_tabs_checkbox->setChecked ( + settings->value ("editor/indent_uses_tabs", false).toBool ()); ui->editor_tab_width_spinbox->setValue ( settings->value ("editor/tab_width", 2).toInt ()); ui->editor_longWindowTitle->setChecked ( @@ -663,6 +665,8 @@ ui->editor_ind_guides_checkbox->isChecked ()); settings->setValue ("editor/indent_width", ui->editor_ind_width_spinbox->value ()); + settings->setValue ("editor/indent_uses_tabs", + ui->editor_ind_uses_tabs_checkbox->isChecked ()); settings->setValue ("editor/tab_width", ui->editor_tab_width_spinbox->value ()); settings->setValue ("editor/longWindowTitle",
--- a/libgui/src/settings-dialog.ui +++ b/libgui/src/settings-dialog.ui @@ -52,8 +52,8 @@ <rect> <x>0</x> <y>0</y> - <width>560</width> - <height>353</height> + <width>678</width> + <height>378</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_17"> @@ -404,9 +404,9 @@ <property name="geometry"> <rect> <x>0</x> - <y>0</y> + <y>-256</y> <width>662</width> - <height>613</height> + <height>634</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_16"> @@ -755,13 +755,6 @@ </property> </widget> </item> - <item row="2" column="4"> - <widget class="QCheckBox" name="editor_tab_ind_checkbox"> - <property name="text"> - <string>Tab indents line</string> - </property> - </widget> - </item> <item row="0" column="5"> <spacer name="horizontalSpacer_14"> <property name="orientation"> @@ -778,6 +771,13 @@ </property> </spacer> </item> + <item row="2" column="4"> + <widget class="QCheckBox" name="editor_tab_ind_checkbox"> + <property name="text"> + <string>Tab indents line</string> + </property> + </widget> + </item> <item row="0" column="4"> <widget class="QCheckBox" name="editor_auto_ind_checkbox"> <property name="text"> @@ -871,6 +871,13 @@ </property> </spacer> </item> + <item row="3" column="4"> + <widget class="QCheckBox" name="editor_ind_uses_tabs_checkbox"> + <property name="text"> + <string>Indentation uses tabs</string> + </property> + </widget> + </item> </layout> </item> <item> @@ -1280,8 +1287,8 @@ <rect> <x>0</x> <y>0</y> - <width>488</width> - <height>262</height> + <width>678</width> + <height>378</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_7"> @@ -1545,8 +1552,8 @@ <rect> <x>0</x> <y>0</y> - <width>474</width> - <height>318</height> + <width>678</width> + <height>378</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_18"> @@ -1709,8 +1716,8 @@ <rect> <x>0</x> <y>0</y> - <width>203</width> - <height>134</height> + <width>678</width> + <height>378</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_19"> @@ -1784,8 +1791,8 @@ <rect> <x>0</x> <y>0</y> - <width>368</width> - <height>244</height> + <width>678</width> + <height>378</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_25"> @@ -2047,8 +2054,8 @@ <rect> <x>0</x> <y>0</y> - <width>529</width> - <height>204</height> + <width>678</width> + <height>378</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_20">
--- a/libinterp/corefcn/profiler.cc +++ b/libinterp/corefcn/profiler.cc @@ -1,5 +1,6 @@ /* +Copyright (C) 2014 Julien Bect Copyright (C) 2012-2013 Daniel Kraft This file is part of Octave. @@ -32,29 +33,6 @@ #include "pager.h" #include "profiler.h" -profile_data_accumulator::enter::enter (profile_data_accumulator& a, - const std::string& f) - : acc (a) -{ - // FIXME: Add test for f != "" to prevent a blank line showing up - // in profiler statistics. See bug #39524. The root cause - // is that the function name is not set for the recurring readline - // hook function. - if (acc.is_active () && f != "") - { - fcn = f; - acc.enter_function (fcn); - } - else - fcn = ""; -} - -profile_data_accumulator::enter::~enter () -{ - if (fcn != "") - acc.exit_function (fcn); -} - profile_data_accumulator::stats::stats () : time (0.0), calls (0), recursive (false), parents (), children ()
--- a/libinterp/corefcn/profiler.h +++ b/libinterp/corefcn/profiler.h @@ -1,5 +1,6 @@ /* +Copyright (C) 2014 Julien Bect Copyright (C) 2012-2013 Daniel Kraft This file is part of Octave. @@ -39,17 +40,40 @@ // This is a utility class that can be used to call the enter/exit // functions in a manner protected from stack unwinding. - class enter + template<class T> class enter { private: profile_data_accumulator& acc; std::string fcn; + bool is_active; public: - enter (profile_data_accumulator&, const std::string&); - virtual ~enter (void); + enter (profile_data_accumulator& a, const T& t) : acc (a) + { + // A profiling block cannot be active if the profiler is not + is_active = acc.is_active (); + + if (is_active) + { + fcn = t.profiler_name (); + + // NOTE: The test f != "" must be kept to prevent a blank line showing + // up in profiler statistics. See bug #39524. The root cause is that + // the function name is not set for the recurring readline hook function. + if (fcn == "") + is_active = false; // Inactive profiling block + else + acc.enter_function (fcn); + } + } + + ~enter () + { + if (is_active) + acc.exit_function (fcn); + } private: @@ -181,10 +205,12 @@ extern OCTINTERP_API profile_data_accumulator profiler; // Helper macro to profile a block of code. -#define BEGIN_PROFILER_BLOCK(name) \ + +#define BEGIN_PROFILER_BLOCK(classname) \ { \ - profile_data_accumulator::enter pe (profiler, (name)); + profile_data_accumulator::enter<classname> pe (profiler, *this); + #define END_PROFILER_BLOCK \ - } + } // end of block => call pe's destructor #endif
--- a/libinterp/octave-value/ov-builtin.cc +++ b/libinterp/octave-value/ov-builtin.cc @@ -127,7 +127,7 @@ try { - BEGIN_PROFILER_BLOCK (profiler_name ()) + BEGIN_PROFILER_BLOCK (octave_builtin) retval = (*f) (args, nargout); // Do not allow null values to be returned from functions.
--- a/libinterp/octave-value/ov-mex-fcn.cc +++ b/libinterp/octave-value/ov-mex-fcn.cc @@ -148,8 +148,10 @@ try { - BEGIN_PROFILER_BLOCK (profiler_name ()) + BEGIN_PROFILER_BLOCK (octave_mex_function) + retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this); + END_PROFILER_BLOCK } catch (octave_execution_exception)
--- a/libinterp/octave-value/ov-usr-fcn.cc +++ b/libinterp/octave-value/ov-usr-fcn.cc @@ -149,8 +149,10 @@ frame.protect_var (tree_evaluator::statement_context); tree_evaluator::statement_context = tree_evaluator::script; - BEGIN_PROFILER_BLOCK (profiler_name ()) + BEGIN_PROFILER_BLOCK (octave_user_script) + cmd_list->accept (*current_evaluator); + END_PROFILER_BLOCK if (tree_return_command::returning) @@ -614,7 +616,7 @@ frame.protect_var (tree_evaluator::statement_context); tree_evaluator::statement_context = tree_evaluator::function; - BEGIN_PROFILER_BLOCK (profiler_name ()) + BEGIN_PROFILER_BLOCK (octave_user_function) if (is_special_expr ()) {
--- a/libinterp/parse-tree/pt-binop.cc +++ b/libinterp/parse-tree/pt-binop.cc @@ -135,7 +135,7 @@ if (! error_state && b.is_defined ()) { - BEGIN_PROFILER_BLOCK ("binary " + oper ()) + BEGIN_PROFILER_BLOCK (tree_binary_expression) // Note: The profiler does not catch the braindead // short-circuit evaluation code above, but that should be
--- a/libinterp/parse-tree/pt-binop.h +++ b/libinterp/parse-tree/pt-binop.h @@ -100,6 +100,9 @@ void accept (tree_walker& tw); + std::string profiler_name (void) const { return "binary " + oper (); } + + protected: // The operands for the expression.
--- a/libinterp/parse-tree/pt-unop.cc +++ b/libinterp/parse-tree/pt-unop.cc @@ -73,8 +73,8 @@ if (! error_state) { - BEGIN_PROFILER_BLOCK ("prefix " + oper ()) - + BEGIN_PROFILER_BLOCK (tree_prefix_expression) + ref.do_unary_op (etype); if (! error_state) @@ -89,7 +89,7 @@ if (! error_state && val.is_defined ()) { - BEGIN_PROFILER_BLOCK ("prefix " + oper ()) + BEGIN_PROFILER_BLOCK (tree_prefix_expression) // Attempt to do the operation in-place if it is unshared // (a temporary expression). @@ -162,8 +162,10 @@ { retval = ref.value (); - BEGIN_PROFILER_BLOCK ("postfix " + oper ()) + BEGIN_PROFILER_BLOCK (tree_postfix_expression) + ref.do_unary_op (etype); + END_PROFILER_BLOCK } } @@ -173,7 +175,7 @@ if (! error_state && val.is_defined ()) { - BEGIN_PROFILER_BLOCK ("postfix " + oper ()) + BEGIN_PROFILER_BLOCK (tree_postfix_expression) retval = ::do_unary_op (etype, val);
--- a/libinterp/parse-tree/pt-unop.h +++ b/libinterp/parse-tree/pt-unop.h @@ -108,6 +108,9 @@ void accept (tree_walker& tw); + std::string profiler_name (void) const { return "prefix " + oper (); } + + private: // No copying! @@ -145,6 +148,8 @@ void accept (tree_walker& tw); + std::string profiler_name (void) const { return "postfix " + oper (); } + private: // No copying!